]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
* mod_proxy: Add the possibility to set the worker parameters
authorJim Jagielski <jim@apache.org>
Tue, 11 Nov 2008 20:01:59 +0000 (20:01 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 11 Nov 2008 20:01:59 +0000 (20:01 +0000)
     connectiontimeout and ping in milliseconds.
     Trunk version of patch:
       http://svn.apache.org/viewvc?rev=705005&view=rev
       http://svn.apache.org/viewvc?rev=707022&view=rev
     Backport version for 2.2.x of patch:
       http://people.apache.org/~rpluem/patches/milli_seconds.diff
     +1: rpluem, pgollucci, jim

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@713145 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
docs/manual/mod/mod_proxy.xml
include/ap_mmn.h
include/httpd.h
modules/proxy/mod_proxy.c
server/util.c

diff --git a/CHANGES b/CHANGES
index 6077cd46716832c6a358af6e252a1a8159119b2f..2dd6a9f9910ec1113de1eab98140f49078f99783 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,11 @@ Changes with Apache 2.2.11
      send the empty body packet, so container can deal with
      that. [Mladen Turk]
 
+  *) core: Add ap_timeout_parameter_parse to public API. [Ruediger Pluem]
+
+  *) mod_proxy: Add the possibility to set the worker parameters
+     connectiontimeout and ping in milliseconds. [Ruediger Pluem]
+
   *) Worker MPM: Crosscheck that idle workers are still available before using
      them and thus preventing an overflow of the worker queue which causes
      a SegFault. PR 45605 [Denis Ustimenko <denusk gmail.com>]
diff --git a/STATUS b/STATUS
index 03eaeef3b3895b37f094d3fe8dbc054ef55b95ff..24085315e0c3a71cbfc63c90271d6ecb55df0622 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -96,15 +96,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
         http://people.apache.org/~rpluem/patches/proxy_alloc_lifetime_rework_2.2.x.diff
      +1: rpluem, pgollucci, jim
 
-   * mod_proxy: Add the possibility to set the worker parameters
-     connectiontimeout and ping in milliseconds. 
-     Trunk version of patch:
-        http://svn.apache.org/viewvc?rev=705005&view=rev
-        http://svn.apache.org/viewvc?rev=707022&view=rev
-     Backport version for 2.2.x of patch:
-        http://people.apache.org/~rpluem/patches/milli_seconds.diff
-     +1: rpluem, pgollucci, jim
-
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
index 8546ab051db5b68a6a9dd2b7e7f248093fff1f4c..b0626faaf29f3027c8816e303931f9e88ff52e4c 100644 (file)
@@ -693,7 +693,8 @@ expressions</description>
         <td>timeout</td>
         <td>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.
     </td></tr>
     <tr><td>disablereuse</td>
         <td>Off</td>
@@ -748,6 +749,8 @@ expressions</description>
         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.
     </td></tr>
     <tr><td>loadfactor</td>
         <td>1</td>
index 411b2d50b42f4bcc98ad5243932abb15263470eb..bbce0ed0ece3f28c2bdc3c5d7343d0c8d6a4f5bb 100644 (file)
  *                      proxy_worker struct.
  * 20051115.17 (2.2.10) Add scolonsep to proxy_balancer
  * 20051115.18 (2.2.10) Add chroot support to unixd_config
+ * 20051115.19 (2.2.11) Added ap_timeout_parameter_parse to util.c / httpd.h
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503232UL /* "AP22" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20051115
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 18                    /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 19                    /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index 542b6eaa7a2e4bc615ac7c9632cd19126cbaa86a..a96e4d620978d7a512251cb4fa9bd293d46bc2fc 100644 (file)
@@ -1734,6 +1734,29 @@ AP_DECLARE(char *) ap_escape_quotes(apr_pool_t *p, const char *instring);
 AP_DECLARE(char *) ap_append_pid(apr_pool_t *p, const char *string,
                                  const char *delim);
 
+/**
+ * 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.
+ */
+AP_DECLARE(apr_status_t) ap_timeout_parameter_parse(
+                                               const char *timeout_parameter,
+                                               apr_interval_time_t *timeout,
+                                               const char *default_time_unit);
+
 /* Misc system hackery */
 /**
  * Given the name of an object in the file system determine if it is a directory
index 7aaa7da7af3199c509840b6dd2ec63fbe3bd0943..453653649a7da47d8a5ef3bc5f67ad1661e1f0d5 100644 (file)
@@ -71,6 +71,8 @@ static const char *set_worker_param(apr_pool_t *p,
 {
 
     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.
@@ -126,14 +128,15 @@ static const char *set_worker_param(apr_pool_t *p,
         worker->smax = ival;
     }
     else if (!strcasecmp(key, "acquire")) {
-        /* Acquire timeout in milliseconds.
+        /* Acquire 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)
-            return "Acquire must be at least one mili second";
-        worker->acquire = apr_time_make(0, ival * 1000);
+        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 = timeout;
         worker->acquire_set = 1;
     }
     else if (!strcasecmp(key, "timeout")) {
@@ -267,22 +270,24 @@ static const char *set_worker_param(apr_pool_t *p,
         worker->lbset = ival;
     }
     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, "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 {
index e1be3d1831d14da7b3072091457f14e38e8b68e7..3c927c23957928cdd7f1d50777d3b496f18d6f06 100644 (file)
@@ -2146,3 +2146,71 @@ AP_DECLARE(char *) ap_append_pid(apr_pool_t *p, const char *string,
                         delim, getpid());
 
 }
+
+/**
+ * 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.
+ */
+AP_DECLARE(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;
+}
+