ca8514
From ced24e032ebe185a2d885fa309d6de47668ba31e Mon Sep 17 00:00:00 2001
ca8514
From: Yann Ylavic <ylavic@apache.org>
ca8514
Date: Fri, 26 Jun 2020 10:21:19 +0000
ca8514
Subject: [PATCH] Merge r1878280 from trunk:
ca8514
ca8514
mod_proxy_http: don't strip EOS when spooling request body to file.
ca8514
ca8514
To prevent stream_reqbody() from sending the FILE and FLUSH bucket in separate
ca8514
brigades, and thus apr_file_setaside() to trigger if network congestion occurs
ca8514
with the backend, restore the EOS in spool_reqbody_cl() which was stripped
ca8514
when spooling the request body to a file.
ca8514
ca8514
Until APR r1878279 is released (and installed by users), apr_file_setaside()
ca8514
on a temporary file (mktemp) will simply drop the file cleanup, leaking the
ca8514
fd and inode..
ca8514
ca8514
This fixes BZ 64452.
ca8514
ca8514
ca8514
Submitted by: ylavic
ca8514
Reviewed by: ylavic, jorton, rpluem
ca8514
ca8514
ca8514
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1879226 13f79535-47bb-0310-9956-ffa450edef68
ca8514
---
ca8514
 modules/proxy/mod_proxy_http.c | 8 ++++++++
ca8514
 1 file changed, 8 insertions(+)
ca8514
ca8514
diff --git a/modules/proxy/mod_proxy_http.c b/modules/proxy/mod_proxy_http.c
ca8514
index e94bf26d412..7a0f063f705 100644
ca8514
--- a/modules/proxy/mod_proxy_http.c
ca8514
+++ b/modules/proxy/mod_proxy_http.c
ca8514
@@ -548,6 +548,14 @@ static int spool_reqbody_cl(proxy_http_req_t *req, apr_off_t *bytes_spooled)
ca8514
         e = apr_bucket_immortal_create(CRLF_ASCII, 2, bucket_alloc);
ca8514
         APR_BRIGADE_INSERT_TAIL(input_brigade, e);
ca8514
     }
ca8514
+    if (tmpfile) {
ca8514
+        /* We dropped metadata buckets when spooling to tmpfile,
ca8514
+         * terminate with EOS for stream_reqbody() to flush the
ca8514
+         * whole in one go.
ca8514
+         */
ca8514
+        e = apr_bucket_eos_create(bucket_alloc);
ca8514
+        APR_BRIGADE_INSERT_TAIL(input_brigade, e);
ca8514
+    }
ca8514
     return OK;
ca8514
 }
ca8514