]> granicus.if.org Git - apache/commitdiff
If we change the LB method, or we take add in a new
authorJim Jagielski <jim@apache.org>
Thu, 31 Mar 2011 17:00:36 +0000 (17:00 +0000)
committerJim Jagielski <jim@apache.org>
Thu, 31 Mar 2011 17:00:36 +0000 (17:00 +0000)
balancermember ("enable" her), then we need to have the
LBmethod reset its params as required...

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1087371 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_balancer.c
modules/proxy/proxy_util.c

index 2a9309cf76262300ede4007d3fd95a2b2c19978a..2fd1952f0c882adaf24d50b221246176939eeab8 100644 (file)
@@ -402,6 +402,7 @@ typedef struct {
     unsigned int    scolonsep:1;      /* true if ';' seps sticky session paths */
     unsigned int    max_attempts_set:1;
     unsigned int    was_malloced:1;
+    unsigned int    need_reset:1;
 } proxy_balancer_shared;
 
 #define ALIGNED_PROXY_BALANCER_SHARED_SIZE (APR_ALIGN_DEFAULT(sizeof(proxy_balancer_shared)))
index 24febdd57f0542cb8774244721340950957f4b1d..f359f9fea979a0727c199656d21bdec909bfb038 100644 (file)
@@ -1007,6 +1007,10 @@ static int balancer_handler(request_rec *r)
         }
         if ((val = apr_table_get(params, "w_status_D"))) {
             ap_proxy_set_wstatus('D', atoi(val), wsel);
+            /* if enabling, we need to reset all lb params */
+            if (bsel && !(atoi(val))) {
+                bsel->s->need_reset = 1;
+            }
         }
         if ((val = apr_table_get(params, "w_status_H"))) {
             ap_proxy_set_wstatus('H', atoi(val), wsel);
@@ -1025,13 +1029,15 @@ static int balancer_handler(request_rec *r)
         int ival;
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "settings balancer params");
         if ((val = apr_table_get(params, "b_lbm"))) {
-            if (strlen(val) < (sizeof(bsel->s->lbpname)-1)) {
+            if ((strlen(val) < (sizeof(bsel->s->lbpname)-1)) &&
+                strcmp(val, bsel->s->lbpname)) {
                 proxy_balancer_method *lbmethod;
-                lbmethod = ap_lookup_provider(PROXY_LBMETHOD, bsel->s->lbpname, "0");
+                lbmethod = ap_lookup_provider(PROXY_LBMETHOD, val, "0");
                 if (lbmethod) {
                     PROXY_STRNCPY(bsel->s->lbpname, val);
                     bsel->lbmethod = lbmethod;
                     bsel->s->wupdated = apr_time_now();
+                    bsel->s->need_reset = 1;
                 }
             }
         }
index c68572ae677842ab72b9224735d8630ab413ecba..8339d40376a2599ebcc005984959d84002d49a77 100644 (file)
@@ -3002,6 +3002,11 @@ PROXY_DECLARE(apr_status_t) ap_proxy_sync_balancer(proxy_balancer *b, server_rec
             }
         }
     }
+    if (b->s->need_reset) {
+        if (b->lbmethod && b->lbmethod->reset)
+            b->lbmethod->reset(b, s);
+        b->s->need_reset = 0;
+    }
     b->wupdated = b->s->wupdated;
     return APR_SUCCESS;
 }