]> granicus.if.org Git - apache/commitdiff
mod_proxy_balancer: Add failontimeout parameter. Timeout will put worker
authorGraham Leggett <minfrin@apache.org>
Sat, 27 Apr 2013 22:32:42 +0000 (22:32 +0000)
committerGraham Leggett <minfrin@apache.org>
Sat, 27 Apr 2013 22:32:42 +0000 (22:32 +0000)
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://people.apache.org/~druggeri/patches/httpd-2.4.x-failontimeout.patch

Submitted by: druggeri
Reviewed by: jim, minfrin

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1476689 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 670d21048922d49dbdffbb7c86cafdae84ad0595..1dcde800e255521f9da0f0b62c63a10d33c8dc01 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@
 
 Changes with Apache 2.4.5
 
+  *) Added balancer parameter failontimeout to allow server admin
+     to configure an IO timeout as an error in the balancer.
+     [Daniel Ruggeri]
+
   *) mod_auth_digest: Fix crashes if shm initialization failed. [Stefan
      Fritsch]
 
diff --git a/STATUS b/STATUS
index e100b0fec6dd5a7a052880f7cf513ba26fa76939..355c88a917137031f6a1e3d697dffbb4b7162ebc 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -90,12 +90,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://people.apache.org/~druggeri/patches/httpd-2.4.x-failontimeout.patch
-     2.2.x patch: http://people.apache.org/~druggeri/patches/httpd-2.2.x-failontimeout.patch
-     +1: druggeri, jim, minfrin
 
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
index 0f64f8f036d4826e00f48e709db69fd8a96581c1..9e84f37c66427d1133915b09427038b59f72b67c 100644 (file)
@@ -1103,6 +1103,13 @@ ProxyPass /mirror/foo http://backend.example.com
         force the worker into error state when the backend returns any status code
         in the list. Worker recovery behaves the same as other worker errors.
     </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 in Apache HTTP Server 2.4.5 and later.
+    </td></tr>
     <tr><td>nonce</td>
         <td>&lt;auto&gt;</td>
         <td>The protective nonce used in the <code>balancer-manager</code> application page.
index 0bd3a6c9f9242b92b2c917c3c2dea5312b219c09..e16baa3daf6663d7c5951a3029e0dae97775bfd8 100644 (file)
@@ -383,6 +383,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, "nonce")) {
         if (!strcasecmp(val, "None")) {
             *balancer->s->nonce = '\0';
index 5074aa1615c2f046fa6550b8877fd420b47dd3ee..ca4bb65e3142acede845458499d0d32969f4fe30 100644 (file)
@@ -446,6 +446,7 @@ struct proxy_balancer {
     proxy_server_conf *sconf;
     void            *context;    /* general purpose storage */
     proxy_balancer_shared *s;    /* Shared data */
+    int failontimeout;           /* Whether to mark a member in Err if IO timeout occurs */
 };
 
 struct proxy_balancer_method {
index cd9987e192ecc4c855bed94c38017a0aba3bf08c..b1fd84eeb5846ec259c1ae2abef3cceb8366be4c 100644 (file)
@@ -649,6 +649,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, APLOGNO(02460)
+                      "%s: Forcing worker (%s) into error state "
+                      "due to timeout and 'failonstatus' parameter being set",
+                       balancer->s->name, worker->s->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_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01175)
                       "%s: Unlock failed for post_request", balancer->s->name);
index 07b5408d3cddbfb5513c7e9767e49d0fd2d449cb..47b28758394541b0f24aff3ea41e05491a89041e 100644 (file)
@@ -1576,6 +1576,7 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
                           "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, APLOGNO(01103) "read timeout");
                 if (do_100_continue) {
                     return ap_proxyerror(r, HTTP_SERVICE_UNAVAILABLE, "Timeout on 100-Continue");