From: Ruediger Pluem Date: Sat, 9 Aug 2008 20:52:46 +0000 (+0000) Subject: * Add the possibility to set a separate connection timeout for backend X-Git-Tag: 2.3.0~382 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4e20c8e556d346039e8336870059d73ebe9a7ec;p=thirdparty%2Fapache%2Fhttpd.git * Add the possibility to set a separate connection timeout for backend workers. PR: 45445 Submitted by: rahul Reviewed by: rpluem git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@684341 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 76585ba2d41..c78b4e01f2d 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,10 @@ Changes with Apache 2.3.0 [ When backported to 2.2.x, remove entry from this file ] + *) mod_proxy: Add connectiontimeout parameter for proxy workers in order to + be able to set the timeout for connecting to the backend separately. + PR 45445. [Ruediger Pluem, rahul ] + *) mod_dav_fs: Retrieve minimal system information about directory entries when walking a DAV fs, resolving a performance degradation on Windows. PR 45464. [Jeff Trawick] diff --git a/docs/manual/mod/mod_proxy.xml b/docs/manual/mod/mod_proxy.xml index 9228e7a833c..e6b30ffa1fe 100644 --- a/docs/manual/mod/mod_proxy.xml +++ b/docs/manual/mod/mod_proxy.xml @@ -697,6 +697,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 b85bc8954ab..f87183a34e8 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -163,6 +163,9 @@ * Rationale: see r661069. * 20080528.1 (2.3.0-dev) add has_realm_hash() to authn_provider struct * 20080722.0 (2.3.0-dev) remove has_realm_hash() from authn_provider struct + * 20080722.1 (2.3.0-dev) Add conn_timeout and conn_timeout_set to + * proxy_worker struct. + * */ #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */ @@ -170,7 +173,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20080722 #endif -#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 1 /* 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 67b91a88c07..775ca5ba577 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -281,6 +281,16 @@ static const char *set_worker_param(apr_pool_t *p, return "lbset must be between 0 and 99"; worker->lbset = ival; } + 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 44918f4fb94..1f1b1d5f394 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -352,6 +352,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 2103b410492..2a55c5bcacd 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -2325,8 +2325,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) { @@ -2364,6 +2367,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; }