Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 87771 invoked from network); 15 Oct 2008 19:44:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Oct 2008 19:44:24 -0000 Received: (qmail 75567 invoked by uid 500); 15 Oct 2008 19:44:25 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 75516 invoked by uid 500); 15 Oct 2008 19:44:25 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 75507 invoked by uid 99); 15 Oct 2008 19:44:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Oct 2008 12:44:25 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Oct 2008 19:43:15 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 891FC238893B; Wed, 15 Oct 2008 12:43:52 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r705005 - in /httpd/httpd/trunk: CHANGES docs/manual/mod/mod_proxy.xml modules/proxy/mod_proxy.c Date: Wed, 15 Oct 2008 19:43:52 -0000 To: cvs@httpd.apache.org From: rpluem@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081015194352.891FC238893B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rpluem Date: Wed Oct 15 12:43:51 2008 New Revision: 705005 URL: http://svn.apache.org/viewvc?rev=705005&view=rev Log: * Add the possibility to set the worker parameters connectiontimeout and ping in milliseconds and the parameter acquire in seconds. Add the new currently static function ap_timeout_parameter_parse that should become a general utility function once its API is hammered out. Modified: httpd/httpd/trunk/CHANGES httpd/httpd/trunk/docs/manual/mod/mod_proxy.xml httpd/httpd/trunk/modules/proxy/mod_proxy.c Modified: httpd/httpd/trunk/CHANGES URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=705005&r1=705004&r2=705005&view=diff ============================================================================== --- httpd/httpd/trunk/CHANGES [utf-8] (original) +++ httpd/httpd/trunk/CHANGES [utf-8] Wed Oct 15 12:43:51 2008 @@ -2,6 +2,9 @@ Changes with Apache 2.3.0 [ When backported to 2.2.x, remove entry from this file ] + *) mod_proxy: Add the possibility to set the worker parameters + connectiontimeout and ping in milliseconds. [Ruediger Pluem] + *) mod_ssl: Send Content-Type application/ocsp-request for POST requests to OSCP responders. PR 46014 [Dr Stephen Henson ] Modified: httpd/httpd/trunk/docs/manual/mod/mod_proxy.xml URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_proxy.xml?rev=705005&r1=705004&r2=705005&view=diff ============================================================================== --- httpd/httpd/trunk/docs/manual/mod/mod_proxy.xml (original) +++ httpd/httpd/trunk/docs/manual/mod/mod_proxy.xml Wed Oct 15 12:43:51 2008 @@ -701,7 +701,8 @@ timeout Connect timeout in seconds. The number of seconds Apache waits for the creation of a connection to - the backend to complete. + the backend to complete. By adding a postfix of ms the timeout can be + also set in milliseconds. disablereuse Off @@ -756,6 +757,8 @@ which could be an issue, but it will lower the traffic in case some of the cluster nodes are down or busy. Currently this has an effect only for AJP. + By adding a postfix of ms the delay can be also set in + milliseconds. redirect - Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=705005&r1=705004&r2=705005&view=diff ============================================================================== --- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original) +++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Wed Oct 15 12:43:51 2008 @@ -41,7 +41,75 @@ return sizeof(proxy_worker_stat); } +/** + * Parse a given timeout parameter string into an apr_interval_time_t value. + * The unit of the time interval is given as postfix string to the numeric + * string. Currently the following units are understood: + * + * ms : milliseconds + * s : seconds + * mi[n] : minutes + * h : hours + * + * If no unit is contained in the given timeout parameter the default_time_unit + * will be used instead. + * @param timeout_parameter The string containing the timeout parameter. + * @param timeout The timeout value to be returned. + * @param default_time_unit The default time unit to use if none is specified + * in timeout_parameter. + * @return Status value indicating whether the parsing was successful or not. + */ +/* + * XXX: Once this function has its final status parameter wise it makes sense + * to move it to some of the util??? files under server/ as public API. + */ +static apr_status_t ap_timeout_parameter_parse(const char *timeout_parameter, + apr_interval_time_t *timeout, + const char *default_time_unit) +{ + char *endp; + const char *time_str; + apr_int64_t tout; + + tout = apr_strtoi64(timeout_parameter, &endp, 10); + if (errno) { + return errno; + } + if (!endp || !*endp) { + time_str = default_time_unit; + } + else { + time_str = endp; + } + switch (*time_str) { + /* Time is in seconds */ + case 's': + *timeout = (apr_interval_time_t) apr_time_from_sec(tout); + break; + case 'h': + /* Time is in hours */ + *timeout = (apr_interval_time_t) apr_time_from_sec(tout * 3600); + break; + case 'm': + switch (*(++time_str)) { + /* Time is in miliseconds */ + case 's': + *timeout = (apr_interval_time_t) tout * 1000; + break; + /* Time is in minutes */ + case 'i': + *timeout = (apr_interval_time_t) apr_time_from_sec(tout * 60); + break; + default: + return APR_EGENERAL; + } + break; + default: + return APR_EGENERAL; + } + return APR_SUCCESS; +} /* * A Web proxy module. Stages: @@ -77,6 +145,8 @@ { int ival; + apr_interval_time_t timeout; + if (!strcasecmp(key, "loadfactor")) { /* Normalized load factor. Used with BalancerMamber, * it is a number between 1 and 100. @@ -132,14 +202,15 @@ worker->smax = ival; } else if (!strcasecmp(key, "acquire")) { - /* Acquire timeout in milliseconds. + /* Acquire timeout in given unit (default is milliseconds). * If set this will be the maximum time to * wait for a free connection. */ - ival = atoi(val); - if (ival < 1) + if (ap_timeout_parameter_parse(val, &timeout, "ms") != APR_SUCCESS) + return "Acquire timeout has wrong format"; + if (timeout < 1000) return "Acquire must be at least one millisecond"; - worker->acquire = apr_time_make(0, ival * 1000); + worker->acquire = timeout; worker->acquire_set = 1; } else if (!strcasecmp(key, "timeout")) { @@ -267,12 +338,13 @@ worker->flush_wait = ival * 1000; /* change to microseconds */ } else if (!strcasecmp(key, "ping")) { - /* Ping/Pong timeout in seconds. + /* Ping/Pong timeout in given unit (default is second). */ - ival = atoi(val); - if (ival < 1) - return "Ping/Pong timeout must be at least one second"; - worker->ping_timeout = apr_time_from_sec(ival); + if (ap_timeout_parameter_parse(val, &timeout, "s") != APR_SUCCESS) + return "Ping/Pong timeout has wrong format"; + if (timeout < 1000) + return "Ping/Pong timeout must be at least one millisecond"; + worker->ping_timeout = timeout; worker->ping_timeout_set = 1; } else if (!strcasecmp(key, "lbset")) { @@ -282,13 +354,14 @@ worker->lbset = ival; } else if (!strcasecmp(key, "connectiontimeout")) { - /* Request timeout in seconds. + /* Request timeout in given unit (default is second). * 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); + if (ap_timeout_parameter_parse(val, &timeout, "s") != APR_SUCCESS) + return "Connectiontimeout has wrong format"; + if (timeout < 1000) + return "Connectiontimeout must be at least one millisecond."; + worker->conn_timeout = timeout; worker->conn_timeout_set = 1; } else {