You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mt...@apache.org on 2007/07/17 16:31:09 UTC

svn commit: r556931 - /httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c

Author: mturk
Date: Tue Jul 17 07:31:05 2007
New Revision: 556931

URL: http://svn.apache.org/viewvc?view=rev&rev=556931
Log:
Return 503 only if the route matches some of the balancer members and nofailover=On is specified.

Modified:
    httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c

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?view=diff&rev=556931&r1=556930&r2=556931
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c Tue Jul 17 07:31:05 2007
@@ -470,15 +470,32 @@
         *worker = runtime;
     }
     else if (route && (*balancer)->sticky_force) {
-        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
-                     "proxy: BALANCER: (%s). All workers are in error state for route (%s)",
-                     (*balancer)->name, route);
-        if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) {
-            ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
-                         "proxy: BALANCER: (%s). Unlock failed for pre_request",
-                         (*balancer)->name);
+        int i, member_of = 0;
+        proxy_worker *workers;
+        /*
+         * We have a route provided that doesn't match the
+         * balancer name. See if the provider route is the
+         * member of the same balancer in which case return 503
+         */
+        workers = (proxy_worker *)(*balancer)->workers->elts;
+        for (i = 0; i < (*balancer)->workers->nelts; i++) {
+            if (*(workers->s->route) && strcmp(workers->s->route, route) == 0) {
+                member_of = 1;
+                break;
+            }
+            workers++;
+        }
+        if (member_of) {
+            ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+                         "proxy: BALANCER: (%s). All workers are in error state for route (%s)",
+                         (*balancer)->name, route);
+            if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) {
+                ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
+                             "proxy: BALANCER: (%s). Unlock failed for pre_request",
+                             (*balancer)->name);
+            }
+            return HTTP_SERVICE_UNAVAILABLE;
         }
-        return HTTP_SERVICE_UNAVAILABLE;
     }
 
     if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) {



Re: svn commit: r556931 - /httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c

Posted by Jim Jagielski <ji...@jaguNET.com>.
On Jul 17, 2007, at 12:48 PM, jean-frederic clere wrote:

> Jim Jagielski wrote:
>> On Jul 17, 2007, at 10:31 AM, mturk@apache.org wrote:
>>> +            if (*(workers->s->route) && strcmp(workers->s- 
>>> >route, route) == 0) {
>> Is that right? I'm guessing the 1st check was to make sure
>> that workers->s->route wasn't NULL (and therefore the strcmp
>> didn't dump), but instead you're checking that the 1st
>> character isn't '\0'... or was that the intent?
>
> It is checking for '\0' see modules/proxy/mod_proxy.h (typedef  
> struct { ... } proxy_worker_stat.
>

Ahh... I had forgotten that route in proxy_worker_stat
was an char [] and not a *char


Re: svn commit: r556931 - /httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c

Posted by jean-frederic clere <jf...@gmail.com>.
Jim Jagielski wrote:
> 
> On Jul 17, 2007, at 10:31 AM, mturk@apache.org wrote:
>> +            if (*(workers->s->route) && strcmp(workers->s->route, 
>> route) == 0) {
> 
> Is that right? I'm guessing the 1st check was to make sure
> that workers->s->route wasn't NULL (and therefore the strcmp
> didn't dump), but instead you're checking that the 1st
> character isn't '\0'... or was that the intent?
> 
> 

It is checking for '\0' see modules/proxy/mod_proxy.h (typedef struct { 
... } proxy_worker_stat.

So *(workers->s->route) && could be removed from the test. Note the same 
code exists in find_route_worker() it could be fixed there too.

Cheers

Jean-Frederic

Re: svn commit: r556931 - /httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c

Posted by Jim Jagielski <ji...@jaguNET.com>.
On Jul 17, 2007, at 10:31 AM, mturk@apache.org wrote:
> +            if (*(workers->s->route) && strcmp(workers->s->route,  
> route) == 0) {

Is that right? I'm guessing the 1st check was to make sure
that workers->s->route wasn't NULL (and therefore the strcmp
didn't dump), but instead you're checking that the 1st
character isn't '\0'... or was that the intent?


Re: svn commit: r556931 - /httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c

Posted by Jim Jagielski <ji...@jaguNET.com>.
On Jul 17, 2007, at 10:31 AM, mturk@apache.org wrote:
> +            if (*(workers->s->route) && strcmp(workers->s->route,  
> route) == 0) {

Is that right? I'm guessing the 1st check was to make sure
that workers->s->route wasn't NULL (and therefore the strcmp
didn't dump), but instead you're checking that the 1st
character isn't '\0'... or was that the intent?