From: William A. Rowe Jr Date: Thu, 30 Jun 2016 17:07:29 +0000 (+0000) Subject: mod_proxy: don't recyle backend announced "Connection: close" connections X-Git-Tag: 2.2.32~122 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f11d960fabdb3f06d7cf98a3a5820e018d22d1ba;p=thirdparty%2Fapache%2Fhttpd.git mod_proxy: don't recyle backend announced "Connection: close" connections to avoid reusing it should the close be effective after some new request is ready to be sent. Backports: r1678763, r1703807, r1703813, r1678763 Submitted by: ylavic Reviewed by: rpluem, wrowe git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@1750836 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 8e4f62b1a24..0ebe8a1aae0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with Apache 2.2.32 + *) mod_proxy: don't recyle backend announced "Connection: close" connections + to avoid reusing it should the close be effective after some new request + is ready to be sent. [Yann Ylavic] + *) mod_substitute: Allow to configure the patterns merge order with the new SubstituteInheritBefore on|off directive. PR 57641 [Marc.Stern , Yann Ylavic, William Rowe] diff --git a/STATUS b/STATUS index 0648b7bbc36..66ee651f080 100644 --- a/STATUS +++ b/STATUS @@ -138,17 +138,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK: 2.2.x patch: trunk works, modulo CHANGES +1: rjung, wrowe, ylavic - *) mod_proxy: don't recyle backend announced "Connection: close" connections - to avoid reusing it should the close be effective after some new request - is ready to be sent. - trunk patch: http://svn.apache.org/r1678763 - http://svn.apache.org/r1703807 - http://svn.apache.org/r1703813 - 2.2.x patch: http://home.apache.org/~ylavic/patches/httpd-2.2.x-mod_proxy-connection_close.patch - +1: ylavic, rpluem, wrowe - ylavic: while at it, I also included r1678763 which is only an - optimization, but allows to keep code in sync with 2.4/trunk. - PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index e4e6371b915..700d4589c41 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -1399,6 +1399,14 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p, } #if APR_HAS_THREADS +static void socket_cleanup(proxy_conn_rec *conn) +{ + conn->sock = NULL; + conn->connection = NULL; + conn->ssl_hostname = NULL; + apr_pool_clear(conn->scpool); +} + static apr_status_t conn_pool_cleanup(void *theworker) { proxy_worker *worker = (proxy_worker *)theworker; @@ -1681,7 +1689,8 @@ static apr_status_t connection_cleanup(void *theconn) #endif /* determine if the connection need to be closed */ - if (!ap_proxy_connection_reusable(conn)) { + if (!worker->is_address_reusable || worker->disablereuse + || conn->close_on_recycle) { apr_pool_t *p = conn->pool; apr_pool_clear(p); conn = apr_pcalloc(p, sizeof(proxy_conn_rec)); @@ -1690,6 +1699,12 @@ static apr_status_t connection_cleanup(void *theconn) apr_pool_create(&(conn->scpool), p); apr_pool_tag(conn->scpool, "proxy_conn_scpool"); } + else if (conn->close + || (conn->connection + && conn->connection->keepalive == AP_CONN_CLOSE)) { + socket_cleanup(conn); + conn->close = 0; + } #if APR_HAS_THREADS if (worker->hmax && worker->cp->res) { conn->inreslist = 1; @@ -1705,14 +1720,6 @@ static apr_status_t connection_cleanup(void *theconn) return APR_SUCCESS; } -static void socket_cleanup(proxy_conn_rec *conn) -{ - conn->sock = NULL; - conn->connection = NULL; - conn->ssl_hostname = NULL; - apr_pool_clear(conn->scpool); -} - PROXY_DECLARE(apr_status_t) ap_proxy_ssl_connection_cleanup(proxy_conn_rec *conn, request_rec *r) {