]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_proxy_balancer: Force workers into PROXY_WORKER_IN_ERROR when configured
authorWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 7 Oct 2010 18:51:18 +0000 (18:51 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 7 Oct 2010 18:51:18 +0000 (18:51 +0000)
statuses are found

PR: 48939
Backports: 930125, 930254, 962972, 987359
Submitted by: Daniel Ruggeri <DRuggeri primary.net>
Reviewed by: trawick, niq, wrowe

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

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

diff --git a/CHANGES b/CHANGES
index ceb90943c3348cc317006c32c291a10e88cca9c3..d23bc8f8152152aa74693b700d0aafd836fde971 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.2.17
 
+  *) Proxy balancer: support setting error status according to HTTP response
+     code from a backend.  PR 48939.  [Daniel Ruggeri <DRuggeri primary.net>]
+
   *) mod_authnz_ldap: If AuthLDAPCharsetConfig is set, also convert the
      password to UTF-8. PR 45318.
      [Johannes Müller <joh_m gmx.de>, Stefan Fritsch]
diff --git a/STATUS b/STATUS
index 2c5d3ec26840e3438e760f93cb7fd64180626899..8f70385116e7e7388d6182fe7693d3535ff0a616 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -87,21 +87,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-    * mod_proxy_balancer: Force workers into PROXY_WORKER_IN_ERROR when configured
-      statuses are found
-      PR: 48939
-      Trunk patches: http://svn.apache.org/viewvc?rev=930125&view=rev
-                     http://svn.apache.org/viewvc?rev=930254&view=rev
-                     http://svn.apache.org/viewvc?rev=962972&view=rev
-                     http://svn.apache.org/viewvc?rev=987359&view=rev
-      2.2.x patch:  https://issues.apache.org/bugzilla/attachment.cgi?id=25923
-      plus this CHANGES entry:
-      *) Proxy balancer: support setting error status according to HTTP response
-         code from a backend.  PR 48939.  [Daniel Ruggeri <DRuggeri primary.net>]
-     Submitted by: Daniel Ruggeri <DRuggeri primary.net>
-     +1: trawick, wrowe
-     niq: +1 to the 2.2.x patch, but why r951900 and r987379 in trunk patches?
-
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
index 44015d93db4ba6503172af9606ebb7dd9fd8c8ab..815e18ae34c8e462e633c2c823d53ff0ad4e5a2a 100644 (file)
@@ -979,6 +979,12 @@ expressions</description>
         <td>Balancer timeout in seconds. If set this will be the maximum time
         to wait for a free worker. Default is not to wait. 
     </td></tr>
+    <tr><td>failonstatus</td>
+        <td>-</td>
+        <td>A single or comma-separated list of HTTP status codes. If set this will
+        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>
     
     </table>
     <p>A sample balancer setup</p>
index eef610ab671b0505e7e73b973b312b6a8aef282c..ba1ca0bfe6a6b1cc155097e6d8db52e0a697a1c1 100644 (file)
  * 20051115.23 (2.2.12) Add ap_open_piped_log_ex API, with cmdtype option,
  *                      and conditional cmdtype member of piped_log struct
  * 20051115.24 (2.2.15) Add forward member to proxy_conn_rec
+ * 20051115.25 (2.2.17) Add errstatuses member to proxy_balancer
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503232UL /* "AP22" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20051115
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 24                    /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 25                    /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index 6a370563fb8ea8e04f448b90d160d94f7c188123..1efe95ce4d060d4f3602a5b09e8c5164f51fa0e7 100644 (file)
@@ -365,6 +365,28 @@ static const char *set_balancer_param(proxy_server_conf *conf,
         else
             return "scolonpathdelim must be On|Off";
     }
+    else if (!strcasecmp(key, "failonstatus")) {
+        char *val_split;
+        char *status;
+        char *tok_state;
+
+        val_split = apr_pstrdup(p, val);
+
+        balancer->errstatuses = apr_array_make(p, 1, sizeof(int));
+
+        status = apr_strtok(val_split, ", ", &tok_state);
+        while (status != NULL) {
+            ival = atoi(status);
+            if (ap_is_HTTP_VALID_RESPONSE(ival)) {
+                *(int *)apr_array_push(balancer->errstatuses) = ival;
+            }
+            else {
+                return "failonstatus must be one or more HTTP response codes";
+            }
+            status = apr_strtok(NULL, ", ", &tok_state);
+        }
+
+    }
     else {
         return "unknown Balancer parameter";
     }
index 358248f1353632201ba61a69f49beea7de29b5fc..4a4bf17bd1d17f7b9e8ed78d766b5e065ab31a45 100644 (file)
@@ -386,6 +386,8 @@ struct proxy_balancer {
 #endif
     void            *context;   /* general purpose storage */
     int             scolonsep;  /* true if ';' seps sticky session paths */
+
+    apr_array_header_t *errstatuses; /* statuses to force members into error */
 };
 
 struct proxy_balancer_method {
index e5a010dbd8bc0422c92e20e6d28571d7cfd52efa..90f3d086edd9caa2402ff720b5464e65d283fb2d 100644 (file)
@@ -591,7 +591,6 @@ static int proxy_balancer_post_request(proxy_worker *worker,
                                        proxy_server_conf *conf)
 {
 
-#if 0
     apr_status_t rv;
 
     if ((rv = PROXY_THREAD_LOCK(balancer)) != APR_SUCCESS) {
@@ -600,8 +599,20 @@ static int proxy_balancer_post_request(proxy_worker *worker,
             balancer->name);
         return HTTP_INTERNAL_SERVER_ERROR;
     }
-    /* TODO: placeholder for post_request actions
-     */
+    if (!apr_is_empty_array(balancer->errstatuses)) {
+        int i;
+        for (i = 0; i < balancer->errstatuses->nelts; i++) {
+            int val = ((int *)balancer->errstatuses->elts)[i];
+            if (r->status == val) {
+                ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
+                             "proxy: BALANCER: (%s).  Forcing recovery for worker (%s), failonstatus %d",
+                             balancer->name, worker->name, val);
+                worker->s->status |= PROXY_WORKER_IN_ERROR;
+                worker->s->error_time = apr_time_now();
+                break;
+            }
+        }
+    }
 
     if ((rv = PROXY_THREAD_UNLOCK(balancer)) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
@@ -611,8 +622,6 @@ static int proxy_balancer_post_request(proxy_worker *worker,
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                  "proxy_balancer_post_request for (%s)", balancer->name);
 
-#endif
-
     if (worker && worker->s->busy)
         worker->s->busy--;