From 3866ae89a41d7856e313c5c0d71c44241011482d Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Tue, 1 Feb 2011 16:00:01 +0000 Subject: [PATCH] We can now change lbmethod at runtime. Provide a stub for other balancer-related params to be adjusted as well, like timeout, sticky, etc... git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1066076 13f79535-47bb-0310-9956-ffa450edef68 --- modules/proxy/mod_proxy.c | 10 ++--- modules/proxy/mod_proxy_balancer.c | 62 ++++++++++++++++++++++++++---- 2 files changed, 59 insertions(+), 13 deletions(-) diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 5b75b1c4f6..4c3f151725 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -1155,11 +1155,11 @@ static void * create_proxy_config(apr_pool_t *p, server_rec *s) ps->reverse = NULL; ps->domain = NULL; #if 0 - id = ap_proxy_hashfunc(apr_psprintf(p, "%pp-%" APR_TIME_T_FMT, ps->noproxies, apr_time_now()), PROXY_HASHFUNC_DEFAULT); + id = ap_proxy_hashfunc(apr_psprintf(p, "%pp-%" APR_TIME_T_FMT, ps, apr_time_now()), PROXY_HASHFUNC_DEFAULT); #else - id = ap_proxy_hashfunc(apr_psprintf(p, "%pp", ps->noproxies), PROXY_HASHFUNC_DEFAULT); + id = ap_proxy_hashfunc(apr_psprintf(p, "%pp", ps), PROXY_HASHFUNC_DEFAULT); #endif - ps->id = apr_psprintf(p, "cnf_%x", id); + ps->id = apr_psprintf(p, "s%x", id); ps->viaopt = via_off; /* initially backward compatible with 1.3.1 */ ps->viaopt_set = 0; /* 0 means default */ ps->req = 0; @@ -2395,8 +2395,8 @@ static int proxy_status_hook(request_rec *r, int flags) "StatWorker status\n" "RouteSession Route\n" "RedirSession Route Redirection\n" - "FLoad Balancer Factor in %\n" - "AccNumber of requests\n" + "FLoad Balancer Factor\n" + "AccNumber of uses\n" "WrNumber of bytes transferred\n" "RdNumber of bytes read\n" "", r); diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index 305674df47..f3f2c71535 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -755,7 +755,10 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog, unsigned int index; balancer->max_workers = balancer->workers->nelts + balancer->growth; - ap_pstr2_alnum(pconf, balancer->name, &balancer->sname); + /* no need for the 'balancer://' prefix */ + ap_pstr2_alnum(pconf, balancer->name + sizeof(BALANCER_PREFIX) - 1, + &balancer->sname); + balancer->sname = apr_pstrcat(pconf, conf->id, "_", balancer->sname, NULL); /* Create global mutex */ rv = ap_global_mutex_create(&(balancer->mutex), NULL, balancer_mutex_type, @@ -839,6 +842,7 @@ static int balancer_handler(request_rec *r) apr_table_t *params; int access_status; int i, n; + int ok2change = 1; const char *name; /* is this for us? */ @@ -897,14 +901,11 @@ static int balancer_handler(request_rec *r) ) ) { apr_table_clear(params); + ok2change = 0; } /* First set the params */ - /* - * Note that it is not possible set the proxy_balancer because it is not - * in shared memory. - */ - if (wsel) { + if (wsel && ok2change) { const char *val; if ((val = apr_table_get(params, "lf"))) { int ival = atoi(val); @@ -940,6 +941,17 @@ static int balancer_handler(request_rec *r) } } + + if (bsel && ok2change) { + const char *val; + if ((val = apr_table_get(params, "lbm"))) { + proxy_balancer_method *lbmethod; + lbmethod = ap_lookup_provider(PROXY_LBMETHOD, val, "0"); + if (lbmethod) + bsel->s->lbmethod = lbmethod; + } + } + if (apr_table_get(params, "xml")) { ap_set_content_type(r, "text/xml"); ap_rputs("\n", r); @@ -984,7 +996,11 @@ static int balancer_handler(request_rec *r) for (i = 0; i < conf->balancers->nelts; i++) { ap_rputs("
\n

LoadBalancer Status for ", r); - ap_rvputs(r, balancer->name, "

\n\n", NULL); + ap_rvputs(r, "uri, "?b=", + balancer->name + sizeof(BALANCER_PREFIX) - 1, + "&nonce=", balancer->s->nonce, + "\">", NULL); + ap_rvputs(r, balancer->name, "\n\n", NULL); ap_rputs("\n\n" "" "\n", r); @@ -1089,10 +1105,40 @@ static int balancer_handler(request_rec *r) bsel->s->nonce, "\">\n", NULL); ap_rvputs(r, "\n", NULL); ap_rputs("
\n", r); + } else if (bsel) { + const apr_array_header_t *provs; + const ap_list_provider_names_t *pname; + int i; + ap_rputs("

Edit balancer settings for ", r); + ap_rvputs(r, bsel->name, "

\n", NULL); + ap_rvputs(r, "uri, "\">\n
\n
MaxMembersStickySessionTimeoutFailoverAttemptsMethod
\n", NULL); + provs = ap_list_provider_names(r->pool, PROXY_LBMETHOD, "0"); + if (provs) { + ap_rputs("", r); + ap_rputs("\n", r); + } + ap_rputs("\n", r); + ap_rputs("\n", r); + ap_rvputs(r, "
LBmethod:\n\n
\nname + sizeof(BALANCER_PREFIX) - 1, + "\">\n", NULL); + ap_rvputs(r, "s->nonce, "\">\n", NULL); + ap_rvputs(r, "\n", NULL); + ap_rputs("
\n", r); } ap_rputs(ap_psignature("",r), r); ap_rputs("\n", r); - } +} return OK; } -- 2.40.0