summaryrefslogtreecommitdiffstats
path: root/modules/proxy/mod_proxy_http.c
diff options
context:
space:
mode:
authorGraham Leggett <minfrin@apache.org>2010-11-16 13:08:38 +0100
committerGraham Leggett <minfrin@apache.org>2010-11-16 13:08:38 +0100
commit662633eacc935f349428318d15d6e84eb9c99b19 (patch)
treeeec99c4208a95b13a9890b835663b69d03636608 /modules/proxy/mod_proxy_http.c
parentRevert r1035504, this was the wrong way to do it. (diff)
downloadapache2-662633eacc935f349428318d15d6e84eb9c99b19.tar.xz
apache2-662633eacc935f349428318d15d6e84eb9c99b19.zip
When the proxy closes the backend connection early, force a setaside on
any buckets still outstanding to ensure they've been copied out of the backend connection's pool and it is safe to release the backend connection. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1035605 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--modules/proxy/mod_proxy_http.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/modules/proxy/mod_proxy_http.c b/modules/proxy/mod_proxy_http.c
index e2204a6c93..5738124748 100644
--- a/modules/proxy/mod_proxy_http.c
+++ b/modules/proxy/mod_proxy_http.c
@@ -1902,7 +1902,6 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
/* Switch the allocator lifetime of the buckets */
ap_proxy_buckets_lifetime_transform(r, bb, pass_bb);
- apr_brigade_cleanup(bb);
/* found the last brigade? */
if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(pass_bb))) {
@@ -1910,6 +1909,23 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
/* signal that we must leave */
finish = TRUE;
+ /* the brigade may contain transient buckets that contain
+ * data that lives only as long as the backend connection.
+ * Force a setaside so these transient buckets become heap
+ * buckets that live as long as the request.
+ */
+ for (e = APR_BRIGADE_FIRST(pass_bb); e
+ != APR_BRIGADE_SENTINEL(pass_bb); e
+ = APR_BUCKET_NEXT(e)) {
+ apr_bucket_setaside(e, r->pool);
+ }
+
+ /* finally it is safe to clean up the brigade from the
+ * connection pool, as we have forced a setaside on all
+ * buckets.
+ */
+ apr_brigade_cleanup(bb);
+
/* make sure we release the backend connection as soon
* as we know we are done, so that the backend isn't
* left waiting for a slow client to eventually
@@ -1930,6 +1946,7 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
/* make sure we always clean up after ourselves */
apr_brigade_cleanup(pass_bb);
+ apr_brigade_cleanup(bb);
} while (!finish);
}