Hi,

I would like to fix a problem in mod_proxy_balancer when the configuration is something like:
+++
  <Location /myapp>
ProxyPass balancer://mycluster/myapp stickysession=JESSSIONID|jsessionid nofailover=On
  </Location>

  <Location /titi>
ProxyPass balancer://mytiti/titi stickysession=JESSSIONID|jsessionid nofailover=On
  </Location>

  <Proxy balancer://mytiti>
    BalancerMember ajp://jfcpc:8009 smax=10 timeout=10 route=test2
  </Proxy>
  <Proxy balancer://mycluster>
    BalancerMember ajp://neo:8009 smax=10 timeout=10 route=toto
  </Proxy>
+++
When jumping from /myapp with a JSESSIONID=id.test2 to /titi httpd returns 500 but it should have ignored the route test2 because it doesn't belong to any of the members of the balancer corresponding to the location.

Find attached a patch to fix the problem.

Comments?

Cheers

Jean-Frederic
Index: modules/proxy/mod_proxy_balancer.c
===================================================================
--- modules/proxy/mod_proxy_balancer.c  (revision 555580)
+++ modules/proxy/mod_proxy_balancer.c  (working copy)
@@ -175,7 +175,7 @@
 /* Find the worker that has the 'route' defined
  */
 static proxy_worker *find_route_worker(proxy_balancer *balancer,
-                                       const char *route, request_rec *r)
+                                       const char *route, int *found, 
request_rec *r)
 {
     int i;
     int checking_standby;
@@ -184,12 +184,14 @@
     proxy_worker *worker;
 
     checking_standby = checked_standby = 0;
+    *found = 0;
     while (!checked_standby) {
         worker = (proxy_worker *)balancer->workers->elts;
         for (i = 0; i < balancer->workers->nelts; i++, worker++) {
             if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : 
PROXY_WORKER_IS_STANDBY(worker)) )
                 continue;
             if (*(worker->s->route) && strcmp(worker->s->route, route) == 0) {
+                *found = 1;
                 if (worker && PROXY_WORKER_IS_USABLE(worker)) {
                     return worker;
                 } else {
@@ -214,7 +216,8 @@
                          */
                         if (*worker->s->redirect) {
                             proxy_worker *rworker = NULL;
-                            rworker = find_route_worker(balancer, 
worker->s->redirect, r);
+                            int found;
+                            rworker = find_route_worker(balancer, 
worker->s->redirect, &found, r);
                             /* Check if the redirect worker is usable */
                             if (rworker && !PROXY_WORKER_IS_USABLE(rworker)) {
                                 /*
@@ -272,12 +275,13 @@
     if ((*route) && ((*route = strchr(*route, '.')) != NULL ))
         (*route)++;
     if ((*route) && (**route)) {
+        int found;
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                                   "proxy: BALANCER: Found route %s", *route);
         /* We have a route in path or in cookie
          * Find the worker that has this route defined.
          */
-        worker = find_route_worker(balancer, *route, r);
+        worker = find_route_worker(balancer, *route, &found, r);
         if (worker && strcmp(*route, worker->s->route)) {
             /*
              * Notice that the route of the worker chosen is different from
@@ -288,6 +292,13 @@
                          "proxy: BALANCER: Route changed from %s to %s",
                          *route, worker->s->route);
         }
+
+        /*
+         * If there is no worker corresponding to the route, the route
+         * doesn't belong to the balancer, ignored it
+         */
+        if (!found)
+            *route = NULL;
         return worker;
     }
     else

Reply via email to