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