From: Jean-Frederic Clere Date: Thu, 22 Apr 2010 13:13:40 +0000 (+0000) Subject: Add updatelbstatus to allow to have all the LB logic in the balancers. X-Git-Tag: 2.3.6~167 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4c4b534813493c8cc14c67a8a6c65fc9fcc52f17;p=apache Add updatelbstatus to allow to have all the LB logic in the balancers. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@936828 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index f5452700fe..60b7bf92e8 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -383,6 +383,7 @@ struct proxy_balancer_method { void *context; /* general purpose storage */ apr_status_t (*reset)(proxy_balancer *balancer, server_rec *s); apr_status_t (*age)(proxy_balancer *balancer, server_rec *s); + apr_status_t (*updatelbstatus)(proxy_balancer *balancer, proxy_worker *elected, server_rec *s); }; #if APR_HAS_THREADS diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index ab4eae5296..317b25b5f3 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -471,28 +471,31 @@ static int proxy_balancer_pre_request(proxy_worker **worker, /* Step 4: find the session route */ runtime = find_session_route(*balancer, r, &route, &sticky, url); if (runtime) { - int i, total_factor = 0; - proxy_worker **workers; - /* We have a sticky load balancer - * Update the workers status - * so that even session routes get - * into account. - */ - workers = (proxy_worker **)(*balancer)->workers->elts; - for (i = 0; i < (*balancer)->workers->nelts; i++) { - /* Take into calculation only the workers that are - * not in error state or not disabled. - * - * TODO: Abstract the below, since this is dependent - * on the LB implementation + if ((*balancer)->lbmethod && (*balancer)->lbmethod->updatelbstatus) { + /* Call the LB implementation */ + (*balancer)->lbmethod->updatelbstatus(*balancer, runtime, r->server); + } + else { /* Use the default one */ + int i, total_factor = 0; + proxy_worker **workers; + /* We have a sticky load balancer + * Update the workers status + * so that even session routes get + * into account. */ - if (PROXY_WORKER_IS_USABLE(*workers)) { - (*workers)->s->lbstatus += (*workers)->s->lbfactor; - total_factor += (*workers)->s->lbfactor; + workers = (proxy_worker **)(*balancer)->workers->elts; + for (i = 0; i < (*balancer)->workers->nelts; i++) { + /* Take into calculation only the workers that are + * not in error state or not disabled. + */ + if (PROXY_WORKER_IS_USABLE(*workers)) { + (*workers)->s->lbstatus += (*workers)->s->lbfactor; + total_factor += (*workers)->s->lbfactor; + } + workers++; } - workers++; + runtime->s->lbstatus -= total_factor; } - runtime->s->lbstatus -= total_factor; runtime->s->elected++; *worker = runtime;