]> granicus.if.org Git - apache/commitdiff
Add failontimeout to allow server admin to mark balancer member in err if IO timeout...
authorDaniel Ruggeri <druggeri@apache.org>
Tue, 9 Apr 2013 00:18:42 +0000 (00:18 +0000)
committerDaniel Ruggeri <druggeri@apache.org>
Tue, 9 Apr 2013 00:18:42 +0000 (00:18 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1465839 13f79535-47bb-0310-9956-ffa450edef68

docs/log-message-tags/next-number
docs/manual/mod/mod_proxy.xml
modules/proxy/mod_proxy.c
modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_ajp.c
modules/proxy/mod_proxy_balancer.c
modules/proxy/mod_proxy_http.c

index 1db299c003761570b87484285ff82694afa53418..ea5f1c5174eccc52e7a1e2adc45b537c6cc914b5 100644 (file)
@@ -1 +1 @@
-2460
+2461
index 1288423308649aedff15b9a37a8c6b761fbf06a8..4de2cb28e924775a2601dcc6749530818abb1a5f 100644 (file)
@@ -1138,6 +1138,12 @@ 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.
+    </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 b5ff09bbc4b0ab055ed88162b3f2479236770c60..58cbfb8315cd181596012ad9ca0f770e4182f9a3 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 a6ab92cc765bf3e99ba747343cfea364f2275bfe..43835b1b767bd554aa83b71cccf1cd6342cee598 100644 (file)
@@ -451,6 +451,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 e796f73b5e4566f98d8357e3e6d00d57e0cb4207..46cda6ed10f86e18bbda2101b9fd0477e72bdb33 100644 (file)
@@ -662,6 +662,7 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
              * but doesn't affect the whole worker.
              */
             if (APR_STATUS_IS_TIMEUP(status) && conn->worker->s->ping_timeout_set) {
+                apr_table_set(r->notes, "proxy_timedout", "1");
                 rv = HTTP_GATEWAY_TIME_OUT;
             }
             else {
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 543afada5161e10e9b429422dd1f2030b17bab23..0712b61d5f1b7bb3faa0d991af226d47cb9bc2ad 100644 (file)
@@ -1312,6 +1312,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");