]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_proxy: don't recyle backend announced "Connection: close" connections
authorWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 30 Jun 2016 17:07:29 +0000 (17:07 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 30 Jun 2016 17:07:29 +0000 (17:07 +0000)
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

CHANGES
STATUS
modules/proxy/proxy_util.c

diff --git a/CHANGES b/CHANGES
index 8e4f62b1a24c2731c354f3b81f34d019aef6a455..0ebe8a1aae0df55f14875bf4126e2c86f5c917a0 100644 (file)
--- 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 <Marc.Stern approach.be>, Yann Ylavic, William Rowe]
diff --git a/STATUS b/STATUS
index 0648b7bbc36c327429b48049adceb4f10bfdd1a0..66ee651f0805df991e23de4b1bed3f9d55201188 100644 (file)
--- 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 ]
index e4e6371b915eed60d52c80ab8c797959263cfbf0..700d4589c41e80f69a5d66c2389371578fd96313 100644 (file)
@@ -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)
 {