]> granicus.if.org Git - apache/commitdiff
mod_proxy_http: Use the "Connection: close" header for requests to
authorJeff Trawick <trawick@apache.org>
Wed, 15 Apr 2015 17:50:46 +0000 (17:50 +0000)
committerJeff Trawick <trawick@apache.org>
Wed, 15 Apr 2015 17:50:46 +0000 (17:50 +0000)
backends not recycling connections (disablereuse), including the default
reverse and forward proxies.

Submitted by: ylavic (and trawick for an old helper function)
Reviewed by: rjung, covener

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1673896 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
include/ap_mmn.h
modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_fcgi.c
modules/proxy/mod_proxy_http.c
modules/proxy/proxy_util.c

diff --git a/CHANGES b/CHANGES
index 48dec809fd0b54ff8adc0d30a0b13604f83b7a8c..88d612714662b76f0eb69142ff633b3fe61dbf20 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -12,6 +12,13 @@ Changes with Apache 2.4.13
      calls r:wsupgrade() can cause a child process crash. 
      [Edward Lu <Chaosed0 gmail.com>]
 
+  *) mod_proxy_http: Use the "Connection: close" header for requests to
+     backends not recycling connections (disablereuse), including the default
+     reverse and forward proxies.  [Yann Ylavic]
+
+  *) mod_proxy: Add ap_connection_reusable() for checking if a connection
+     is reusable as of this point in processing.  [Jeff Trawick]
+
   *) core_filters: restore/disable TCP_NOPUSH option after non-blocking
      sendfile.  [Yann Ylavic]
 
diff --git a/STATUS b/STATUS
index 29443368bdf46ba8d34e26f63e18f243213071bf..45606a7612c5f3d944ff8c78e18831be16cd4c2c 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -105,14 +105,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  *) mod_proxy_http: Use the "Connection: close" header for requests to
-     backends not recycling connections (disablereuse), including the default
-     reverse and forward proxies.
-     trunk patch: http://svn.apache.org/r1526189
-                  http://svn.apache.org/r1658765
-     2.4.x patch: http://people.apache.org/~ylavic/httpd-2.4.x-ap_proxy_connection_reusable.patch
-     +1: ylavic, rjung, covener
-
   *) mod_ssl: Protect ENGINE_CTRL_CHIL_SET_FORKCHECK macro with a 
      featue check for libressl. 
      trunk patch: http://svn.apache.org/r1673455
index ea3d71ee17caf1e95ab6ae21e23c0cce507b5383..fbd7e4c7b04626cc0734c5de78aca4ed39d604c6 100644 (file)
  * 20120211.43 (2.4.13-dev) Add keep_alive_timeout_set to server_rec
  * 20120211.44 (2.4.13-dev) Add cgi_pass_auth and AP_CGI_PASS_AUTH_* to 
  *                          core_dir_config
+ * 20120211.45 (2.4.13-dev) Add ap_proxy_connection_reusable()
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20120211
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 44                   /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 45                   /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index 89f5c0951ae77feee80d1cb5d437c0d22242dcc3..f54c6b3ee7cd8fcfe54c81259d05009073ab3717 100644 (file)
@@ -889,6 +889,17 @@ PROXY_DECLARE(apr_status_t) ap_proxy_connect_uds(apr_socket_t *sock,
 PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function,
                                               proxy_conn_rec *conn,
                                               conn_rec *c, server_rec *s);
+
+/**
+ * Determine if proxy connection can potentially be reused at the
+ * end of this request.
+ * @param conn proxy connection
+ * @return non-zero if reusable, 0 otherwise
+ * @note Even if this function returns non-zero, the connection may
+ * be subsequently marked for closure.
+ */
+PROXY_DECLARE(int) ap_proxy_connection_reusable(proxy_conn_rec *conn);
+
 /**
  * Signal the upstream chain that the connection to the backend broke in the
  * middle of the response. This is done by sending an error bucket with
index 4a06fd133efab622da89aa07e7985bfab5f43c0f..0e33545d788a3b13e2271a468939384c873de087 100644 (file)
@@ -225,7 +225,9 @@ static apr_status_t send_begin_request(proxy_conn_rec *conn,
     ap_fcgi_fill_in_header(&header, AP_FCGI_BEGIN_REQUEST, request_id,
                            sizeof(abrb), 0);
 
-    ap_fcgi_fill_in_request_body(&brb, AP_FCGI_RESPONDER, AP_FCGI_KEEP_CONN);
+    ap_fcgi_fill_in_request_body(&brb, AP_FCGI_RESPONDER,
+                                 ap_proxy_connection_reusable(conn)
+                                     ? AP_FCGI_KEEP_CONN : 0);
 
     ap_fcgi_header_to_array(&header, farray);
     ap_fcgi_begin_request_body_to_array(&brb, abrb);
index 9ca39176749983113b9ed746d6f63f5d65c4b792..7665f828ce00f9dc2d7858f37ad87c49cd92f059 100644 (file)
@@ -922,7 +922,7 @@ skip_body:
      * otherwise sent Connection: Keep-Alive.
      */
     if (!force10) {
-        if (p_conn->close) {
+        if (!ap_proxy_connection_reusable(p_conn)) {
             buf = apr_pstrdup(p, "Connection: close" CRLF);
         }
         else {
index e47a5a0f36ebd0e55b7638fe1ae88784a5b9cfd1..734e4abe6620f00af771450d55cb649a05e61ebd 100644 (file)
@@ -1351,6 +1351,13 @@ static void init_conn_pool(apr_pool_t *p, proxy_worker *worker)
     worker->cp = cp;
 }
 
+PROXY_DECLARE(int) ap_proxy_connection_reusable(proxy_conn_rec *conn)
+{
+    proxy_worker *worker = conn->worker;
+
+    return ! (conn->close || !worker->s->is_address_reusable || worker->s->disablereuse);
+}
+
 static apr_status_t connection_cleanup(void *theconn)
 {
     proxy_conn_rec *conn = (proxy_conn_rec *)theconn;
@@ -1379,7 +1386,7 @@ static apr_status_t connection_cleanup(void *theconn)
     }
 
     /* determine if the connection need to be closed */
-    if (conn->close || !worker->s->is_address_reusable || worker->s->disablereuse) {
+    if (!ap_proxy_connection_reusable(conn)) {
         apr_pool_t *p = conn->pool;
         apr_pool_clear(p);
         conn = apr_pcalloc(p, sizeof(proxy_conn_rec));