]> granicus.if.org Git - apache/commitdiff
Merge r1619483 from trunk:
authorJim Jagielski <jim@apache.org>
Sat, 19 Mar 2016 13:26:41 +0000 (13:26 +0000)
committerJim Jagielski <jim@apache.org>
Sat, 19 Mar 2016 13:26:41 +0000 (13:26 +0000)
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

STATUS
modules/filters/mod_deflate.c

diff --git a/STATUS b/STATUS
index 57047e4cefcadfd8c4ab3691591046b8272838a3..547e1e95f31e7d0218b1ff244db8fcaf13ea82a4 100644 (file)
--- 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 ]
index 9f6a8c921d0a38e5117f504c37fd528bfca1f9db..142846089f4c1e466ab3761a58eaefe0a791d906 100644 (file)
@@ -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)