]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_proxy_balancer: Add failontimeout parameter. Timeout will put worker
authorWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 27 Jun 2013 16:22:31 +0000 (16:22 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 27 Jun 2013 16:22:31 +0000 (16:22 +0000)
in error state if an IO timeout is detected.

Backports: r1465839
Submitted by: druggeri
Reviewed by: druggeri, wrowe, rjung

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

CHANGES
STATUS
docs/manual/mod/mod_proxy.xml
modules/proxy/mod_proxy.c
modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_balancer.c
modules/proxy/mod_proxy_http.c

diff --git a/CHANGES b/CHANGES
index 88184dfa98d6d8bf835702413413009a4ba653fd..0a8b573e2e84c4c760f130f436b2112a17068d14 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -24,6 +24,10 @@ Changes with Apache 2.2.25
   *) mod_dav: Ensure URI is correctly uriencoded on return. PR 54611
      [Timothy Wood <tjw omnigroup.com>]
 
+  *) Added balancer parameter failontimeout to allow server admin
+     to configure an IO timeout as an error in the balancer.
+     [Daniel Ruggeri]
+
 Changes with Apache 2.2.24
 
   *) SECURITY: CVE-2012-3499 (cve.mitre.org)
diff --git a/STATUS b/STATUS
index 4dafed0fac75d9e2bd50aec962e037bac2714481..ce53524b04b541d06e3b5968dda588448b25cfab 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -114,15 +114,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
   
-  * mod_proxy_balancer: Add failontimeout parameter. Timeout will put worker
-    in error state if an IO timeout is detected.
-    trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1465839
-    2.4.x patch: http://svn.apache.org/viewvc?view=revision&revision=1476689
-    2.2.x patch: http://people.apache.org/~druggeri/patches/httpd-2.2.x-failontimeout.patch
-    +1: druggeri, wrowe, rjung
-    rjung: it would be nice to fix the indentation for the new
-           ap_log_rerror(...) in modules/proxy/mod_proxy_balancer.c.
-
   * mod_dav: Make sure that when we prepare an If URL for Etag comparison,     
     we compare unencoded paths. PR 53910 [Timothy Wood <tjw omnigroup com>]
     trunk patch: http://svn.apache.org/r1470940
index eca80f7de0ff533959b951a8bf51519f4333bced..2224886f3a70b9ea5eb9c4b3b8ef8f0361559dc7 100644 (file)
@@ -1005,6 +1005,13 @@ expressions</description>
         in the list. Worker recovery behaves the same as other worker errors.
         Available with Apache HTTP Server 2.2.17 and later.
     </td></tr>
+    <tr><td>failontimeout</td>
+        <td>Off</td>
+        <td>If set, an IO read timeout after a request is sent to the backend will
+        force the worker into error state. Worker recovery behaves the same as other
+        worker errors.
+        Available with Apache HTTP Server 2.2.25 and later.
+    </td></tr>
     <tr><td>forcerecovery</td>
         <td>On</td>
         <td>Force the immediate recovery of all workers without considering the
index 8f8b61914e573673dc4b0806fcd888ebf8cd5a66..a72b339095e619aedcf94794859cbe7868754de9 100644 (file)
@@ -387,6 +387,14 @@ static const char *set_balancer_param(proxy_server_conf *conf,
         }
 
     }
+    else if (!strcasecmp(key, "failontimeout")) {
+        if (!strcasecmp(val, "on"))
+            balancer->failontimeout = 1;
+        else if (!strcasecmp(val, "off"))
+            balancer->failontimeout = 0;
+        else
+            return "failontimeout must be On|Off";
+    }
     else if (!strcasecmp(key, "forcerecovery")) {
         if (!strcasecmp(val, "on"))
             balancer->forcerecovery = 1;
index 759ae4a66ef4d77e20aa662c740f67079fa9b8a9..99048445f3faba09bd1265dae44f7bdae3012e6b 100644 (file)
@@ -389,6 +389,7 @@ struct proxy_balancer {
 
     apr_array_header_t *errstatuses; /* statuses to force members into error */
     int forcerecovery; /* Force recovery if all workers are in error state */
+    int failontimeout;          /* Whether to mark a member in Err if IO timeout occurs */
 };
 
 struct proxy_balancer_method {
index cc0400666134bcaf2c0f627eb06edc854cd6855d..3a1aea996e753ae60960b031e44184abe9257e27 100644 (file)
@@ -629,6 +629,17 @@ static int proxy_balancer_post_request(proxy_worker *worker,
         }
     }
 
+    if (balancer->failontimeout
+        && (apr_table_get(r->notes, "proxy_timedout")) != NULL) {
+          ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                        "%s: Forcing worker (%s) into error state "
+                        "due to timeout and 'failonstatus' parameter being set",
+                        balancer->name, worker->name);
+        worker->s->status |= PROXY_WORKER_IN_ERROR;
+        worker->s->error_time = apr_time_now();
+
+    }
+
     if ((rv = PROXY_THREAD_UNLOCK(balancer)) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
             "proxy: BALANCER: (%s). Unlock failed for post_request",
index 19c82f2c8aa9a17f2f85bf15c342283d866ba856..ba01c68152fc18c8d44052e6809aede681a1c7df 100644 (file)
@@ -1410,6 +1410,7 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
                           "proxy: error reading status line from remote "
                           "server %s:%d", backend->hostname, backend->port);
             if (APR_STATUS_IS_TIMEUP(rc)) {
+                apr_table_set(r->notes, "proxy_timedout", "1");
                 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                               "proxy: read timeout");
             }