]> granicus.if.org Git - apache/commitdiff
mod_deflate: follow up to r1619444.
authorYann Ylavic <ylavic@apache.org>
Thu, 21 Aug 2014 16:44:10 +0000 (16:44 +0000)
committerYann Ylavic <ylavic@apache.org>
Thu, 21 Aug 2014 16:44:10 +0000 (16:44 +0000)
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

modules/filters/mod_deflate.c

index 1a418d5155a88ace8ec75b224aac1b7cd5c25904..ddc0db2aaf84f304eda78e91800909869f5ec438 100644 (file)
@@ -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)