From c9c2f193a7ecad9a759e2420d09e2f926941e147 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Wed, 14 Nov 2007 16:25:00 +0000 Subject: [PATCH] Some fixes before we move this to an example's dir, but remove the unneeded CORE_PRIVATE and bypass inf loop, but *still* this is not intended to be a module to *use* but rather as an example that yes, you can add lbmethods via sub-module prvider. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@594931 13f79535-47bb-0310-9956-ffa450edef68 --- modules/proxy/mod_lbmethod_rr.c | 39 +++++++++++++++------------------ 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/modules/proxy/mod_lbmethod_rr.c b/modules/proxy/mod_lbmethod_rr.c index 7fca58190f..b7f4f0f0ad 100644 --- a/modules/proxy/mod_lbmethod_rr.c +++ b/modules/proxy/mod_lbmethod_rr.c @@ -14,15 +14,13 @@ * limitations under the License. */ -/* Round Robin lbmethod module for Apache proxy */ +/* Round Robin lbmethod EXAMPLE module for Apache proxy */ /* NOTE: This is designed simply to provide some info on how to create extra lbmethods via sub-modules... This code is ugly and needs work to actually do round-robin "right" but that is left as an exercise for the reader */ -#define CORE_PRIVATE - #include "mod_proxy.h" #include "scoreboard.h" #include "ap_mpm.h" @@ -70,26 +68,25 @@ static proxy_worker *find_best_roundrobin(proxy_balancer *balancer, "proxy: roundrobin index: %d (%d)", ctx->index, (int)getpid()); - do { - checking_standby = checked_standby = 0; - while (!mycandidate && !checked_standby) { - worker = (proxy_worker *)balancer->workers->elts; - - for (i = 0; i < balancer->workers->nelts; i++, worker++) { - if (i < ctx->index) - continue; - if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) ) - continue; - if (!PROXY_WORKER_IS_USABLE(worker)) - ap_proxy_retry_worker("BALANCER", worker, r->server); - if (PROXY_WORKER_IS_USABLE(worker)) { - mycandidate = worker; - break; - } + checking_standby = checked_standby = 0; + while (!mycandidate && !checked_standby) { + worker = (proxy_worker *)balancer->workers->elts; + + for (i = 0; i < balancer->workers->nelts; i++, worker++) { + if (i < ctx->index) + continue; + if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) ) + continue; + if (!PROXY_WORKER_IS_USABLE(worker)) + ap_proxy_retry_worker("BALANCER", worker, r->server); + if (PROXY_WORKER_IS_USABLE(worker)) { + mycandidate = worker; + break; } - checked_standby = checking_standby++; } - } while (!mycandidate); + checked_standby = checking_standby++; + } + ctx->index += 1; if (ctx->index >= balancer->workers->nelts) { -- 2.40.0