From: Yann Ylavic Date: Thu, 21 May 2015 16:35:11 +0000 (+0000) Subject: Merge r1526189, r1658765 from trunk. X-Git-Tag: 2.2.30~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcaa236441457f04e294d99a8737950eda389199;p=thirdparty%2Fapache%2Fhttpd.git Merge r1526189, r1658765 from trunk. 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 --- diff --git a/CHANGES b/CHANGES index f594dc9b4fd..08f97ed1f8c 100644 --- 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 a0bfe65d168..7d5645b2f6a 100644 --- 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 ] diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 6956adbd027..eb2a4a67ac3 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -156,6 +156,7 @@ * 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" */ @@ -163,7 +164,7 @@ #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 diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 78e20bdd35b..ef1ce06961f 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -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 diff --git a/modules/proxy/mod_proxy_http.c b/modules/proxy/mod_proxy_http.c index 932b62182b2..24ca8eca3ce 100644 --- a/modules/proxy/mod_proxy_http.c +++ b/modules/proxy/mod_proxy_http.c @@ -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 { diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index fccf13d235f..b6a62c1069f 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -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));