]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1526189, r1658765 from trunk.
authorYann Ylavic <ylavic@apache.org>
Thu, 21 May 2015 16:35:11 +0000 (16:35 +0000)
committerYann Ylavic <ylavic@apache.org>
Thu, 21 May 2015 16:35:11 +0000 (16:35 +0000)
r1526189 | trawick | 2013-09-25 16:29:02 +0200 (Wed, 25 Sep 2013) | 8 lines

mod_proxy: Add ap_connection_reusable() for checking if a connection
is reusable as of this point in processing.

mod_proxy_fcgi uses the new API to determine if FCGI_CONN_CLOSE
should be enabled, but that doesn't change existing behavior
since the connection is currently marked for closure elsewhere
in the module.

r1658765 | ylavic | 2015-02-10 18:25:54 +0100 (Tue, 10 Feb 2015) | 4 lines

mod_proxy_http: Use the "Connection: close" header for requests to
backends not recycling connections (disablereuse), including the default
reverse and forward proxies.

Reviewed by: ylavic, wrowe, rjung
Backported by: ylavic

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

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

diff --git a/CHANGES b/CHANGES
index f594dc9b4fd1827a9f2d154663cbc0b6628e3c84..08f97ed1f8ceb785aed30602fcb80fe23c11861c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,13 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.2.30
 
+  *) 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]
+
   *) mod_proxy: Reuse proxy/balancer workers' parameters and scores across
      graceful restarts, even if new workers are added, old ones removed, or
      the order changes.  [Jan Kaluza, Yann Ylavic]
diff --git a/STATUS b/STATUS
index a0bfe65d168bf6ba9ee34a3100ea27fc1b5fc437..7d5645b2f6a096c72aae23c322ca43eb9fd9837e 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -118,15 +118,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
              vulnerable per se (no ErrorDocument handling from early
              request line parser), better be safe than sorry.
 
-   * 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: merged in http://svn.apache.org/r1673896
-     2.2.x patch: http://people.apache.org/~ylavic/httpd-2.2.x-ap_proxy_connection_reusable.patch
-     +1: ylavic, wrowe, rjung
-
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
index 6956adbd027a4576f1d70a71da201f096c58103c..eb2a4a67ac320e7c22655201aae61eb5d93dac27 100644 (file)
  * 20051115.36 (2.2.28) Add r->trailers_{in,out}
  * 20051115.37 (2.2.30) Add ap_get_server_name_for_url()
  * 20051115.38 (2.2.30) Add ap_proxy_set_scoreboard_lb() in mod_proxy.h
+ * 20051115.39 (2.2.30) Add ap_proxy_connection_reusable()
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503232UL /* "AP22" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20051115
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 38                    /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 39                    /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index 78e20bdd35bb6962225d70150153e7412cc67939..ef1ce06961fcb7147ba00e99ec00c70e7de16bfd 100644 (file)
@@ -742,6 +742,17 @@ PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
 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 932b62182b27e5bddb1d138e2e2a4cfc1248ddd4..24ca8eca3ce6a81d7a0efc1321d99adfd73dc670 100644 (file)
@@ -1122,7 +1122,7 @@ skip_body:
      * otherwise sent Connection: Keep-Alive.
      */
     if (!force10) {
-        if (p_conn->close || p_conn->close_on_recycle) {
+        if (!ap_proxy_connection_reusable(p_conn)) {
             buf = apr_pstrdup(p, "Connection: close" CRLF);
         }
         else {
index fccf13d235f69970b74a1a24fea0672560e90c48..b6a62c1069ff0a0fdb8bc3a8a5d0476f301d32f5 100644 (file)
@@ -1647,6 +1647,14 @@ PROXY_DECLARE(int) ap_proxy_connect_to_backend(apr_socket_t **newsock,
     return connected ? 0 : 1;
 }
 
+PROXY_DECLARE(int) ap_proxy_connection_reusable(proxy_conn_rec *conn)
+{
+    proxy_worker *worker = conn->worker;
+
+    return ! (conn->close || conn->close_on_recycle
+              || !worker->is_address_reusable || worker->disablereuse);
+}
+
 static apr_status_t connection_cleanup(void *theconn)
 {
     proxy_conn_rec *conn = (proxy_conn_rec *)theconn;
@@ -1672,8 +1680,7 @@ static apr_status_t connection_cleanup(void *theconn)
 #endif
 
     /* determine if the connection need to be closed */
-    if (conn->close_on_recycle || conn->close || worker->disablereuse ||
-        !worker->is_address_reusable) {
+    if (!ap_proxy_connection_reusable(conn)) {
         apr_pool_t *p = conn->pool;
         apr_pool_clear(p);
         conn = apr_pcalloc(p, sizeof(proxy_conn_rec));