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