httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ruediger Pluem <rpl...@apache.org>
Subject Re: svn commit: r594659 - /httpd/httpd/trunk/modules/proxy/mod_lbmethod_rr.c
Date Tue, 13 Nov 2007 22:11:40 GMT


On 11/13/2007 10:55 PM, jim@apache.org wrote:
> Author: jim
> Date: Tue Nov 13 13:55:05 2007
> New Revision: 594659
> 
> URL: http://svn.apache.org/viewvc?rev=594659&view=rev
> Log:
> Add extremely butt-ugly sub-mod that exists simply to show how
> to use providers in sub-mods to extend lbmethods in mod_proxy...
> 
> Added:
>     httpd/httpd/trunk/modules/proxy/mod_lbmethod_rr.c   (with props)
> 
> Added: httpd/httpd/trunk/modules/proxy/mod_lbmethod_rr.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_lbmethod_rr.c?rev=594659&view=auto
> ==============================================================================
> --- httpd/httpd/trunk/modules/proxy/mod_lbmethod_rr.c (added)
> +++ httpd/httpd/trunk/modules/proxy/mod_lbmethod_rr.c Tue Nov 13 13:55:05 2007

> +static proxy_worker *find_best_roundrobin(proxy_balancer *balancer,
> +                                         request_rec *r)
> +{
> +    int i;
> +    proxy_worker *worker;
> +    proxy_worker *mycandidate = NULL;
> +    int checking_standby;
> +    int checked_standby;
> +    rr_data *ctx;
> +
> +    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
> +                 "proxy: Entering roundrobin for BALANCER %s (%d)",
> +                 balancer->name, (int)getpid());
> +    
> +    /* The index of the candidate last chosen is stored in ctx->index */
> +    if (!balancer->context) {
> +        /* UGLY */
> +        ctx = apr_pcalloc(r->server->process->pconf, sizeof(rr_data));
> +        balancer->context = (void *)ctx;
> +        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
> +                 "proxy: Creating roundrobin ctx for BALANCER %s (%d)",
> +                 balancer->name, (int)getpid());
> +    } else {
> +        ctx = (rr_data *)balancer->context;
> +    }
> +    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
> +                 "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;
> +                }
> +            }
> +            checked_standby = checking_standby++;
> +        }
> +    } while (!mycandidate);

Isn't this an endless loop if all workers (standby *and* not standby) are in error mode?
I guess it is reasonable to return NULL in this case and let mod_proxy_balancer handle
this (which it actually does in find_best_worker.

Regards

RĂ¼diger


Mime
View raw message