3d1f4a9
3d1f4a9
http://issues.apache.org/bugzilla/show_bug.cgi?id=36780
3d1f4a9
3d1f4a9
--- httpd-2.2.4/server/util_filter.c.oldflush
3d1f4a9
+++ httpd-2.2.4/server/util_filter.c
3d1f4a9
@@ -578,8 +578,18 @@ AP_DECLARE_NONSTD(apr_status_t) ap_filte
3d1f4a9
                                                 void *ctx)
3d1f4a9
 {
3d1f4a9
     ap_filter_t *f = ctx;
3d1f4a9
+    apr_status_t rv;
3d1f4a9
 
3d1f4a9
-    return ap_pass_brigade(f, bb);
3d1f4a9
+    rv = ap_pass_brigade(f, bb);
3d1f4a9
+
3d1f4a9
+    /* apr_brigade_write* require that the flush function ensures that
3d1f4a9
+     * the brigade is empty upon return; otherwise the brigade may be
3d1f4a9
+     * left with a transient bucket whose contents have fallen out of
3d1f4a9
+     * scope.  Call cleanup here unconditionally to avoid the issue in
3d1f4a9
+     * all cases. */
3d1f4a9
+    apr_brigade_cleanup(bb);
3d1f4a9
+
3d1f4a9
+    return rv;
3d1f4a9
 }
3d1f4a9
 
3d1f4a9
 AP_DECLARE(apr_status_t) ap_fflush(ap_filter_t *f, apr_bucket_brigade *bb)