From: Jim Jagielski Date: Wed, 17 Sep 2008 14:23:35 +0000 (+0000) Subject: * mod_proxy: Add the possibility to set a separate connection timeout for X-Git-Tag: 2.2.10~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97c70b20f28c602100ae57a428397c1716d78e80;p=thirdparty%2Fapache%2Fhttpd.git * mod_proxy: Add the possibility to set a separate connection timeout for backend workers. PR: 45445 Trunk version of patch: http://svn.apache.org/viewvc?rev=684341&view=rev Backport version for 2.2.x of patch: Trunk version of patch works, but http://people.apache.org/~rpluem/patches/37770_2.2.x.diff fixes a conflict regarding the needed minor bump. +1: rpluem, jim, jerenkrantz git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@696316 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index d5883a952ba..b5d3d0d5c33 100644 --- a/CHANGES +++ b/CHANGES @@ -18,6 +18,10 @@ Changes with Apache 2.2.10 *) mod_ssl: Rewrite shmcb to avoid memory alignment issues. PR 42101. [Geoff Thorpe] + *) mod_proxy_http: Introduce environment variable proxy-initial-not-pooled to + avoid reusing pooled connections if the client connection is an initial + connection. PR 37770. [Ruediger Pluem] + *) mod_dav_fs: Retrieve minimal system information about directory entries when walking a DAV fs, resolving a performance degradation on Windows. PR 45464. [Joe Orton, Jeff Trawick] diff --git a/docs/manual/mod/mod_proxy.xml b/docs/manual/mod/mod_proxy.xml index 8bfc3187b07..bebe75e275b 100644 --- a/docs/manual/mod/mod_proxy.xml +++ b/docs/manual/mod/mod_proxy.xml @@ -689,6 +689,12 @@ expressions connections in the pool the Apache will return SERVER_BUSY status to the client. + connectiontimeout + timeout + Connect timeout in seconds. + The number of seconds Apache waits for the creation of a connection to + the backend to complete. + disablereuse Off This parameter should be used when you want to force mod_proxy diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 2c226b6cc62..656189df53d 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -128,6 +128,8 @@ * structure * 20051115.15(2.2.9) Add interpolate_env to proxy_dir_conf and * introduce proxy_req_conf. + * 20051115.16(2.2.9) Add conn_timeout and conn_timeout_set to + * proxy_worker struct. * */ @@ -136,7 +138,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20051115 #endif -#define MODULE_MAGIC_NUMBER_MINOR 15 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 16 /* 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 00bcfebafe6..a6c50242c45 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -275,6 +275,16 @@ static const char *set_worker_param(apr_pool_t *p, worker->ping_timeout = apr_time_from_sec(ival); worker->ping_timeout_set = 1; } + else if (!strcasecmp(key, "connectiontimeout")) { + /* Request timeout in seconds. + * Defaults to connection timeout + */ + ival = atoi(val); + if (ival < 1) + return "Connectiontimeout must be at least one second."; + worker->conn_timeout = apr_time_from_sec(ival); + worker->conn_timeout_set = 1; + } else { return "unknown Worker parameter"; } diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index fdb48bf33fc..2381515c5dd 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -355,6 +355,8 @@ struct proxy_worker { char retry_set; char disablereuse; char disablereuse_set; + apr_interval_time_t conn_timeout; + char conn_timeout_set; }; /* diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index abc056cd535..028bd1abc79 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -2329,8 +2329,11 @@ PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function, "Failed to set"); } - /* Set a timeout on the socket */ - if (worker->timeout_set == 1) { + /* Set a timeout for connecting to the backend on the socket */ + if (worker->conn_timeout_set) { + apr_socket_timeout_set(newsock, worker->conn_timeout); + } + else if (worker->timeout_set == 1) { apr_socket_timeout_set(newsock, worker->timeout); } else if (conf->timeout_set == 1) { @@ -2368,6 +2371,17 @@ PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function, continue; } + /* Set a timeout on the socket */ + if (worker->timeout_set == 1) { + apr_socket_timeout_set(newsock, worker->timeout); + } + else if (conf->timeout_set == 1) { + apr_socket_timeout_set(newsock, conf->timeout); + } + else { + apr_socket_timeout_set(newsock, s->timeout); + } + conn->sock = newsock; connected = 1; }