From: Jim Jagielski Date: Sat, 19 Mar 2016 13:26:41 +0000 (+0000) Subject: Merge r1619483 from trunk: X-Git-Tag: 2.4.19~38 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=17d007d4c0948b92484de0f297b08a2c242abca5;p=apache Merge r1619483 from trunk: 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. Submitted by: ylavic Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1735771 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/STATUS b/STATUS index 57047e4cef..547e1e95f3 100644 --- a/STATUS +++ b/STATUS @@ -112,12 +112,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - *) mod_deflate: follow up to r1619444 (and to r1619383). (backported in r1669555) - Fix counting of inflated bytes in deflate_in_filter() when - asked to flush - trunk patch: http://svn.apache.org/r1619483 - 2.4.x patch: trunk works - +1: ylavic, icing, trawick PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/modules/filters/mod_deflate.c b/modules/filters/mod_deflate.c index 9f6a8c921d..142846089f 100644 --- a/modules/filters/mod_deflate.c +++ b/modules/filters/mod_deflate.c @@ -1254,7 +1254,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) @@ -1262,11 +1265,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) @@ -1286,10 +1285,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 @@ -1350,9 +1352,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) @@ -1361,7 +1363,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)