b04572
# ./pullrev.sh 1847624
b04572
http://svn.apache.org/viewvc?view=revision&revision=1847624
b04572
b04572
https://bugzilla.redhat.com/show_bug.cgi?id=1654200
b04572
b04572
--- mod_fcgid-2.3.9/modules/fcgid/fcgid_proc_unix.c
b04572
+++ mod_fcgid-2.3.9/modules/fcgid/fcgid_proc_unix.c
b04572
@@ -762,14 +762,18 @@
b04572
     struct iovec vec[FCGID_VEC_COUNT];
b04572
     int nvec = 0;
b04572
     apr_bucket *e;
b04572
+    apr_bucket_brigade *tmpbb = apr_brigade_create(output_brigade->p,
b04572
+                                                   output_brigade->bucket_alloc);
b04572
 
b04572
-    for (e = APR_BRIGADE_FIRST(output_brigade);
b04572
-         e != APR_BRIGADE_SENTINEL(output_brigade);
b04572
-         e = APR_BUCKET_NEXT(e)) {
b04572
+    while (!APR_BRIGADE_EMPTY(output_brigade))
b04572
+    {
b04572
+        e = APR_BRIGADE_FIRST(output_brigade);
b04572
+
b04572
         apr_size_t len;
b04572
         const char* base;
b04572
 
b04572
         if (APR_BUCKET_IS_METADATA(e)) {
b04572
+            apr_bucket_delete(e);
b04572
             continue;
b04572
         }
b04572
 
b04572
@@ -780,6 +784,9 @@
b04572
             return rv;
b04572
         }
b04572
 
b04572
+        APR_BUCKET_REMOVE(e);
b04572
+        APR_BRIGADE_INSERT_TAIL(tmpbb, e);
b04572
+
b04572
         vec[nvec].iov_len = len;
b04572
         vec[nvec].iov_base = (char*) base;
b04572
         if (nvec == (FCGID_VEC_COUNT - 1)) {
b04572
@@ -789,6 +796,7 @@
b04572
                                FCGID_VEC_COUNT)) != APR_SUCCESS)
b04572
                 return rv;
b04572
             nvec = 0;
b04572
+            apr_brigade_cleanup(tmpbb);
b04572
         }
b04572
         else
b04572
             nvec++;
b04572
@@ -800,6 +808,7 @@
b04572
             return rv;
b04572
     }
b04572
 
b04572
+    apr_brigade_destroy(tmpbb);
b04572
     return APR_SUCCESS;
b04572
 }
b04572
 
b04572
--- mod_fcgid-2.3.9/modules/fcgid/fcgid_proc_win.c
b04572
+++ mod_fcgid-2.3.9/modules/fcgid/fcgid_proc_win.c
b04572
@@ -380,19 +380,22 @@
b04572
     apr_bucket *bucket_request;
b04572
     apr_status_t rv;
b04572
     DWORD transferred;
b04572
+    apr_bucket_brigade *tmpbb = apr_brigade_create(birgade_send->p, 
b04572
+                                                   birgade_send->bucket_alloc);
b04572
 
b04572
     handle_info = (fcgid_namedpipe_handle *) ipc_handle->ipc_handle_info;
b04572
 
b04572
-    for (bucket_request = APR_BRIGADE_FIRST(birgade_send);
b04572
-         bucket_request != APR_BRIGADE_SENTINEL(birgade_send);
b04572
-         bucket_request = APR_BUCKET_NEXT(bucket_request))
b04572
-    {
b04572
+    while (!APR_BRIGADE_EMPTY(birgade_send)) {
b04572
         const char *write_buf;
b04572
         apr_size_t write_buf_len;
b04572
         apr_size_t has_write;
b04572
 
b04572
-        if (APR_BUCKET_IS_METADATA(bucket_request))
b04572
+        bucket_request = APR_BRIGADE_FIRST(birgade_send);
b04572
+
b04572
+        if (APR_BUCKET_IS_METADATA(bucket_request)) {
b04572
+            apr_bucket_delete(bucket_request);
b04572
             continue;
b04572
+        }
b04572
 
b04572
         if ((rv = apr_bucket_read(bucket_request, &write_buf, &write_buf_len,
b04572
                                   APR_BLOCK_READ)) != APR_SUCCESS) {
b04572
@@ -401,6 +404,9 @@
b04572
             return rv;
b04572
         }
b04572
 
b04572
+        APR_BUCKET_REMOVE(bucket_request);
b04572
+        APR_BRIGADE_INSERT_TAIL(tmpbb, bucket_request);
b04572
+
b04572
         /* Write the buffer to fastcgi server */
b04572
         has_write = 0;
b04572
         while (has_write < write_buf_len) {
b04572
@@ -411,6 +417,7 @@
b04572
                           write_buf_len - has_write,
b04572
                           &byteswrite, &handle_info->overlap_write)) {
b04572
                 has_write += byteswrite;
b04572
+                apr_brigade_cleanup(tmpbb);
b04572
                 continue;
b04572
             } else if ((rv = GetLastError()) != ERROR_IO_PENDING) {
b04572
                 ap_log_rerror(APLOG_MARK, APLOG_WARNING,
b04572
@@ -437,6 +444,7 @@
b04572
                         return APR_ESPIPE;
b04572
                     }
b04572
                     has_write += transferred;
b04572
+                    apr_brigade_cleanup(tmpbb);
b04572
                     continue;
b04572
                 } else {
b04572
                     ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0,
b04572
@@ -448,6 +456,7 @@
b04572
         }
b04572
     }
b04572
 
b04572
+    apr_brigade_destroy(tmpbb);
b04572
     return APR_SUCCESS;
b04572
 }
b04572