httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r930125 - in /httpd/httpd/trunk: CHANGES modules/proxy/mod_proxy.c modules/proxy/mod_proxy.h modules/proxy/mod_proxy_balancer.c
Date Thu, 01 Apr 2010 22:48:38 GMT
Author: niq
Date: Thu Apr  1 22:48:38 2010
New Revision: 930125

URL: http://svn.apache.org/viewvc?rev=930125&view=rev
Log:
Proxy balancer: support setting error status according to
HTTP response code from a backend.
PR 48939 [Daniel Ruggeri <DRuggeri primary.net>]

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/proxy/mod_proxy.c
    httpd/httpd/trunk/modules/proxy/mod_proxy.h
    httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=930125&r1=930124&r2=930125&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Thu Apr  1 22:48:38 2010
@@ -28,6 +28,10 @@ Changes with Apache 2.3.7
      processing is completed, avoiding orphaned callback pointers.
      [Brett Gervasoni <brettg senseofsecurity.com>, Jeff Trawick]
 
+  *) Proxy balancer: support setting error status according to
+     HTTP response code from a backend.
+     PR 48939 [Daniel Ruggeri <DRuggeri primary.net>]
+
   *) htcacheclean: Introduce the ability to clean specific URLs from the
      cache, if provided as an optional parameter on the command line.
      [Graham Leggett]

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=930125&r1=930124&r2=930125&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Thu Apr  1 22:48:38 2010
@@ -381,6 +381,27 @@ static const char *set_balancer_param(pr
         else
             return "scolonpathdelim must be On|Off";
     }
+    else if (!strcasecmp(key, "erroronstatus")) {
+        char valSplit[strlen(val)+1];
+        char *status;
+        char *tok_state;
+
+        strcpy(valSplit, val);
+        balancer->errstatuses = apr_array_make(p, 1, sizeof(int));
+
+        status = apr_strtok(valSplit, ", ", &tok_state);
+        while (status != NULL) {
+            ival = atoi(status);
+            if (ap_is_HTTP_VALID_RESPONSE(ival)) {
+                *(int*)apr_array_push(balancer->errstatuses) = ival;
+            }
+            else {
+                return "erroronstatus must be one or more HTTP response code";
+            }
+            status = apr_strtok(NULL, ", ", &tok_state);
+        }
+
+    }
     else {
         return "unknown Balancer parameter";
     }

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=930125&r1=930124&r2=930125&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Thu Apr  1 22:48:38 2010
@@ -373,6 +373,7 @@ struct proxy_balancer {
     void            *context;   /* general purpose storage */
     const char      *sticky_path;  /* URL sticky session identifier */
     int             scolonsep;     /* true if ';' seps sticky session paths */
+    apr_array_header_t *errstatuses; /* statuses to force members into error */
 };
 
 struct proxy_balancer_method {

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c?rev=930125&r1=930124&r2=930125&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c Thu Apr  1 22:48:38 2010
@@ -600,7 +600,6 @@ static int proxy_balancer_post_request(p
                                        proxy_server_conf *conf)
 {
 
-#if 0
     apr_status_t rv;
 
     if ((rv = PROXY_THREAD_LOCK(balancer)) != APR_SUCCESS) {
@@ -609,8 +608,20 @@ static int proxy_balancer_post_request(p
             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_NOTICE, rv, r->server,
+                    "Detected ErrorOnState (%d) for member (%s). Forcing worker into error
state.", val, worker->name);
+                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,
@@ -620,8 +631,6 @@ static int proxy_balancer_post_request(p
     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--;
 



Mime
View raw message