-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRC32 calculation for upstream subrequests #90
Comments
Solved by updating Line 366 in 808fb55
I'll send a pr |
The fix in #91 didn't work. By using s3fs the module calculates the crc32 properly. |
The subrequest context is supposed to be set here: Lines 570 to 572 in 808fb55
I wonder if that's not happening for some reason. |
+1 having same issue |
When serving the files going into the zip directly from nginx (and not pre-calculating the Line 371 in 5b2604b
happens both p and len values are zero here, which causes the ngx_crc32_update() to run with length 0.Lines 394 to 395 in 5b2604b
The value of sr_ctx does appear to be correct.
Bit more background nginx set up as reverse proxy with upstream serving requests for the zip listings so the upstream will return items such as
Those files are then served by the reverse proxy itself ( If instead of serving the
However this does:
|
When I debug that out, the pointer is
and ngx_http_zip_subrequest_body_filter
I get this output:
Which shows that the request setting and retrieing the context is the same, and that the pointer to the sr_ctx is retrievable right after it's set, but that trying to retrieve the same context in the body filter points to zeros. To me this suggests the context is being nullified elsewhere, before we get to the body filter. |
When I create diff --git a/ngx_http_zip_module.c b/ngx_http_zip_module.c
index cbd448e..fcfd4fc 100644
--- a/ngx_http_zip_module.c
+++ b/ngx_http_zip_module.c
@@ -11,6 +11,7 @@
#include "ngx_http_zip_file.h"
#include "ngx_http_zip_headers.h"
+static ngx_http_zip_sr_ctx_t *global_sr_ctx;
static ngx_chain_t *ngx_chain_last_link(ngx_chain_t *chain_link);
static ngx_int_t ngx_http_zip_discard_chain(ngx_http_request_t *r,
ngx_chain_t *in);
@@ -334,7 +335,7 @@ ngx_http_zip_subrequest_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
{
ngx_http_zip_sr_ctx_t *sr_ctx;
- sr_ctx = ngx_http_get_module_ctx(r, ngx_http_zip_module);
+ sr_ctx = global_sr_ctx;
if (in && sr_ctx && sr_ctx->requesting_file->missing_crc32) {
uint32_t old_crc32 = sr_ctx->requesting_file->crc32;
@@ -542,7 +543,8 @@ ngx_http_zip_send_file_piece(ngx_http_request_t *r, ngx_http_zip_ctx_t *ctx,
sr_ctx->requesting_file = piece->file;
- ngx_http_set_ctx(sr, sr_ctx, ngx_http_zip_module);
+ global_sr_ctx = sr_ctx;
+
if (ctx->wait) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"mod_zip : only one subrequest may be waited at the same time; ");
This fails when there are >1 requests with subrequests happening, causing all subrequests' chunks to add on to a single running crc32 value. |
I discovered that disabling buffering for files that are to be zipped resolves the incorrect CRC32 checksum issue. To fix this, add |
#111 fixes the problem at the source. |
@mdineen, even with that commit applied, I am still getting zero values for CRC-32. @arsenetar's approach to add a different |
Adding files from block storage with
-
as checksum causes the module to calculate the crc-32. Adding the same file from an upstream results in000000
for the checksum, which causes validation errors in some Windows file browsers.Can we have the module calculate the crc-32 for upstream files?
The text was updated successfully, but these errors were encountered: