]> granicus.if.org Git - apache/commitdiff
* We can ignore Z_BUF_ERROR in flush_libz_buffer because:
authorRuediger Pluem <rpluem@apache.org>
Sat, 29 Jul 2006 13:03:43 +0000 (13:03 +0000)
committerRuediger Pluem <rpluem@apache.org>
Sat, 29 Jul 2006 13:03:43 +0000 (13:03 +0000)
  When we call libz_func we can assume that

   - avail_in is zero (due to the surrounding code that calls
     flush_libz_buffer)
   - avail_out is non zero due to the fact that we just emptied
     the output buffer and stored it into a brigade

  So the only reason for Z_BUF_ERROR is that the internal libz
  buffers are now empty and thus we called libz_func one time
  too often. This does not hurt. It simply says that we are done.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@426793 13f79535-47bb-0310-9956-ffa450edef68

modules/filters/mod_deflate.c

index 5dab2b47da97b90c34121c3728d7da43ab50d66c..1b7b1fe1843a77cf50481a6fe038da733766e04d 100644 (file)
@@ -258,8 +258,22 @@ static int flush_libz_buffer(deflate_ctx *ctx, deflate_filter_config *c,
 
          zRC = libz_func(&ctx->stream, flush);
 
-         if (deflate_len == 0 && zRC == Z_BUF_ERROR)
+         /*
+          * We can ignore Z_BUF_ERROR because:
+          * When we call libz_func we can assume that
+          *
+          * - avail_in is zero (due to the surrounding code that calls
+          *   flush_libz_buffer)
+          * - avail_out is non zero due to our actions some lines above
+          *
+          * So the only reason for Z_BUF_ERROR is that the internal libz
+          * buffers are now empty and thus we called libz_func one time
+          * too often. This does not hurt. It simply says that we are done.
+          */
+         if (zRC == Z_BUF_ERROR) {
              zRC = Z_OK;
+             break;
+         }
 
          done = (ctx->stream.avail_out != 0 || zRC == Z_STREAM_END);