From: Jim Jagielski Date: Tue, 13 May 2008 20:32:39 +0000 (+0000) Subject: * mod_proxy: Add in 'disablereuse' option for parity with similar X-Git-Tag: 2.2.9~163 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d685b82b399828bd72993c619001cb2cdb2c01d;p=thirdparty%2Fapache%2Fhttpd.git * mod_proxy: Add in 'disablereuse' option for parity with similar mod_jk functionality. http://svn.apache.org/viewvc?view=rev&revision=627728 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@655998 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index bc38a6cd502..dc16438a190 100644 --- a/CHANGES +++ b/CHANGES @@ -36,6 +36,10 @@ Changes with Apache 2.2.9 or remote port can be logged. PR 43415. [Adam Hasselbalch Hansen , Ruediger Pluem, Jeff Trawick] + *) Added 'disablereuse' option for ProxyPass which, essentially, + disables connection pooling for the backend servers. + [Jim Jagielski] + *) mod_speling: remove regression from 1.3/2.0 behavior and drop dependency between mod_speling and AcceptPathInfo. PR 43562 [Jose Kahan ] diff --git a/STATUS b/STATUS index bd35d33ddb2..e2c310e8cae 100644 --- a/STATUS +++ b/STATUS @@ -98,16 +98,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK: Trunk version works +1: fielding, rpluem, niq - * mod_proxy: Add in 'disablereuse' option for parity with similar - mod_jk functionality. - Trunk version of patch: - http://svn.apache.org/viewvc?view=rev&revision=627728 - Backport version for 2.2.x of patch: - http://people.apache.org/~jim/patches/proxy-disablereuse-v2.txt - +1: jim, rpluem - niq: +1 with the proviso that there's still a typo in the docs in - proxy-disablereuse-v2.txt. But it's fixed in r655986. - PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/docs/manual/mod/mod_proxy.xml b/docs/manual/mod/mod_proxy.xml index dc544779a4c..39f40fd69fe 100644 --- a/docs/manual/mod/mod_proxy.xml +++ b/docs/manual/mod/mod_proxy.xml @@ -663,6 +663,17 @@ expressions in the pool the Apache will return SERVER_BUSY status to the client. + disablereuse + Off + This parameter should be used when you want to force mod_proxy + to immediately close a connection to the backend after being used, and + thus, disable its persistent connection and pool for that backend. + This helps in various situations where a firewall between Apache and + the backend server (regardless of protocol) tends to silently + drop connections or when backends themselves may be under round- + robin DNS. To prevent mod_proxy from reusing the backend connection, + set this property value to On. + flushpackets off Determines whether the proxy module will auto-flush the output diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 7c9a3b05a7d..058a4506bbd 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -120,7 +120,9 @@ * 20051115.9 (2.2.7) Add ap_send_interim_response API * 20051115.10(2.2.7) Added ap_mod_status_reqtail (minor) * 20051115.11(2.2.7) Add *ftp_directory_charset to proxy_dir_conf - * 20051115.12(2.2.8) Add optional function ap_logio_add_bytes_in() to mog_logio + * 20051115.12(2.2.8) Add optional function ap_logio_add_bytes_in() to mog_logio + * 20051115.13(2.2.9) Add disablereuse and disablereuse_set + * to proxy_worker struct (minor) * */ @@ -129,7 +131,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20051115 #endif -#define MODULE_MAGIC_NUMBER_MINOR 12 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 13 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index de48638bc3d..06c8b3384de 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -168,6 +168,15 @@ static const char *set_worker_param(apr_pool_t *p, return "KeepAlive must be On|Off"; worker->keepalive_set = 1; } + else if (!strcasecmp(key, "disablereuse")) { + if (!strcasecmp(val, "on")) + worker->disablereuse = 1; + else if (!strcasecmp(val, "off")) + worker->disablereuse = 0; + else + return "DisableReuse must be On|Off"; + worker->disablereuse_set = 1; + } else if (!strcasecmp(key, "route")) { /* Worker route. */ diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 3944104ebf0..8628d65a997 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -337,6 +337,8 @@ struct proxy_worker { apr_interval_time_t ping_timeout; char ping_timeout_set; char retry_set; + char disablereuse; + char disablereuse_set; }; /* diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index fb2c40a09c6..d3c227e7837 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -1617,7 +1617,8 @@ static apr_status_t connection_cleanup(void *theconn) #endif /* determine if the connection need to be closed */ - if (conn->close_on_recycle || conn->close) { + if (conn->close_on_recycle || conn->close || worker->disablereuse || + !worker->is_address_reusable) { apr_pool_t *p = conn->pool; apr_pool_clear(conn->pool); memset(conn, 0, sizeof(proxy_conn_rec)); @@ -1771,8 +1772,13 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, ser if (!worker->retry_set) { worker->retry = apr_time_from_sec(PROXY_WORKER_DEFAULT_RETRY); } - /* By default address is reusable */ - worker->is_address_reusable = 1; + /* By default address is reusable unless DisableReuse is set */ + if (worker->disablereuse) { + worker->is_address_reusable = 0; + } + else { + worker->is_address_reusable = 1; + } #if APR_HAS_THREADS ap_mpm_query(AP_MPMQ_MAX_THREADS, &mpm_threads); @@ -1984,7 +1990,8 @@ ap_proxy_determine_connection(apr_pool_t *p, request_rec *r, * * TODO: Handle this much better... */ - if (!conn->hostname || !worker->is_address_reusable || + if (!conn->hostname || !worker->is_address_reusable || + worker->disablereuse || (r->connection->keepalives && (r->proxyreq == PROXYREQ_PROXY || r->proxyreq == PROXYREQ_REVERSE) && (strcasecmp(conn->hostname, uri->hostname) != 0) ) ) {