From: Yann Ylavic Date: Thu, 21 Aug 2014 16:44:10 +0000 (+0000) Subject: mod_deflate: follow up to r1619444. X-Git-Tag: 2.5.0-alpha~3877 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=681606bbfa5936f21f9552fa961c47f313d8b455;p=apache mod_deflate: follow up to r1619444. Fix counting of inflated bytes in deflate_in_filter() when asked to flush, since we now count bytes per inflate() call everywhere, we can't count all the produced bytes there. We still need to include all the produced bytes in the brigade. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1619483 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/filters/mod_deflate.c b/modules/filters/mod_deflate.c index 1a418d5155..ddc0db2aaf 100644 --- a/modules/filters/mod_deflate.c +++ b/modules/filters/mod_deflate.c @@ -1290,7 +1290,10 @@ static apr_status_t deflate_in_filter(ap_filter_t *f, if (APR_BUCKET_IS_FLUSH(bkt)) { apr_bucket *tmp_b; + + ctx->inflate_total += ctx->stream.avail_out; zRC = inflate(&(ctx->stream), Z_SYNC_FLUSH); + ctx->inflate_total -= ctx->stream.avail_out; if (zRC != Z_OK) { inflateEnd(&ctx->stream); ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(01391) @@ -1298,11 +1301,7 @@ static apr_status_t deflate_in_filter(ap_filter_t *f, ctx->stream.msg); return APR_EGENERAL; } - - ctx->stream.next_out = ctx->buffer; - len = c->bufferSize - ctx->stream.avail_out; - ctx->inflate_total += len; if (inflate_limit && ctx->inflate_total > inflate_limit) { inflateEnd(&ctx->stream); ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(02647) @@ -1322,10 +1321,13 @@ static apr_status_t deflate_in_filter(ap_filter_t *f, return APR_EINVAL; } + len = c->bufferSize - ctx->stream.avail_out; ctx->crc = crc32(ctx->crc, (const Bytef *)ctx->buffer, len); tmp_b = apr_bucket_heap_create((char *)ctx->buffer, len, NULL, f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(ctx->proc_bb, tmp_b); + + ctx->stream.next_out = ctx->buffer; ctx->stream.avail_out = c->bufferSize; /* Flush everything so far in the returning brigade, but continue @@ -1386,9 +1388,9 @@ static apr_status_t deflate_in_filter(ap_filter_t *f, ctx->stream.avail_out = c->bufferSize; } - len = ctx->stream.avail_out; + ctx->inflate_total += ctx->stream.avail_out; zRC = inflate(&ctx->stream, Z_NO_FLUSH); - + ctx->inflate_total -= ctx->stream.avail_out; if (zRC != Z_OK && zRC != Z_STREAM_END) { inflateEnd(&ctx->stream); ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(01392) @@ -1397,7 +1399,6 @@ static apr_status_t deflate_in_filter(ap_filter_t *f, return APR_EGENERAL; } - ctx->inflate_total += len - ctx->stream.avail_out; if (inflate_limit && ctx->inflate_total > inflate_limit) { inflateEnd(&ctx->stream); ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(02648)