From 9bdff3874d66d3564e0db9d97f845395c6cb6ec7 Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Wed, 11 Aug 2004 22:58:30 +0000 Subject: [PATCH] The lbstatus needs to be updated for every worker, not just the candidate. Submitted by: mturk git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@104613 13f79535-47bb-0310-9956-ffa450edef68 --- modules/proxy/proxy_balancer.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/modules/proxy/proxy_balancer.c b/modules/proxy/proxy_balancer.c index b83da582c5..4a5b7dd2d9 100644 --- a/modules/proxy/proxy_balancer.c +++ b/modules/proxy/proxy_balancer.c @@ -134,7 +134,7 @@ static proxy_runtime_worker *find_best_worker(proxy_balancer *balancer, request_rec *r) { int i; - double total_status = 0.0; + double total_factor = 0.0; proxy_runtime_worker *worker = (proxy_runtime_worker *)balancer->workers->elts; proxy_runtime_worker *candidate = NULL; @@ -153,7 +153,11 @@ static proxy_runtime_worker *find_best_worker(proxy_balancer *balancer, if (worker->w->cp->nfree > candidate->w->cp->nfree) candidate = worker; } - total_status += worker->lbstatus; + /* Total factor should allways be 100. + * This is for cases when worker is in error state. + * It will force the even request distribution + */ + total_factor += worker->lbfactor; } worker++; } @@ -204,12 +208,20 @@ static proxy_runtime_worker *find_best_worker(proxy_balancer *balancer, } worker++; } - /* XXX: The lbfactor can be update using bytes transfered - * Right now, use the round-robin scheme - */ - candidate->lbstatus += candidate->lbfactor; - if (candidate->lbstatus >= total_status) - candidate->lbstatus = candidate->lbfactor; + for (i = 0; i < balancer->workers->nelts; i++) { + /* If the worker is not error state + * or not in disabled mode + */ + if (worker->w->status > 2) { + /* XXX: The lbfactor can be update using bytes transfered + * Right now, use the round-robin scheme + */ + worker->lbstatus += worker->lbfactor; + if (worker->lbstatus >= total_factor) + worker->lbstatus = worker->lbfactor; + } + worker++; + } } return candidate; } -- 2.40.0