On 02/04/2011 09:01 PM, [email protected] wrote:
> Author: jim
> Date: Fri Feb 4 20:01:04 2011
> New Revision: 1067269
>
> URL: http://svn.apache.org/viewvc?rev=1067269&view=rev
> Log:
> Here we go... we can now, via balancer-manager, add new
> workers to existing balancers. Still work to be done,
> like error checking that we aren't trying to add more
> than we can (right now, it fails, but it would be nice
> to handle it nicer), disabling and *deleting* workers
> we don't want anymore, the actual drain method, etc...
> but this is some major goodness.
>
> Modified:
> httpd/httpd/trunk/modules/proxy/mod_proxy.c
> httpd/httpd/trunk/modules/proxy/mod_proxy.h
> httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c
> httpd/httpd/trunk/modules/proxy/proxy_util.c
>
URL:
http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c?rev=1067269&r1=1067268&r2=1067269&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c (original)
> +++ httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c Fri Feb 4 20:01:04
> 2011
> @@ -475,7 +475,7 @@ static int proxy_balancer_pre_request(pr
>
> /* Step 3.5: Update member list for the balancer */
> /* TODO: Implement as provider! */
> - /* proxy_update_members(balancer, r, conf); */
> + ap_proxy_update_members(*balancer, r->server, conf);
Don't we need a lock here as well or better simply doing a lock in
ap_proxy_update_members?
>
> /* Step 4: find the session route */
> runtime = find_session_route(*balancer, r, &route, &sticky, url);
ap_rvputs(r, "value='", bsel->name + sizeof(BALANCER_PREFIX) - 1,
> @@ -1262,6 +1306,57 @@ static void balancer_child_init(apr_pool
>
> }
>
> +PROXY_DECLARE(apr_status_t) ap_proxy_update_members(proxy_balancer *b,
> server_rec *s,
> + proxy_server_conf *conf)
> +{
> + proxy_worker **workers;
> + int i;
> + unsigned int index;
> + proxy_worker_shared *shm;
> + if (b->s->wupdated <= b->wupdated)
> + return APR_SUCCESS;
> + /*
> + * Look thru the list of workers in shm
> + * and see which one(s) we are lacking
> + */
> + for (index = 0; index < b->max_workers; index++) {
> + int found;
> + apr_status_t rv;
> + if ((rv = storage->dptr(b->slot, index, (void *)&shm)) !=
> APR_SUCCESS) {
> + ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "worker
> slotmem_dptr failed");
> + return APR_EGENERAL;
> + }
> + if (!shm->hash)
> + continue;
Can't we do a break here?
> + found = 0;
> + workers = (proxy_worker **)b->workers->elts;
> + for (i = 0; i < b->workers->nelts; i++, workers++) {
> + proxy_worker *worker = *workers;
> + if (worker->hash == shm->hash) {
> + found = 1;
> + break;
> + }
> + }
> + if (!found) {
> + proxy_worker **runtime;
> + runtime = apr_array_push(b->workers);
> + *runtime = apr_palloc(conf->pool, sizeof(proxy_worker));
> + (*runtime)->hash = shm->hash;
> + (*runtime)->context = NULL;
> + (*runtime)->cp = NULL;
> + (*runtime)->mutex = NULL;
> + (*runtime)->balancer = b;
> + (*runtime)->s = shm;
> + if ((rv = ap_proxy_initialize_worker(*runtime, s, conf->pool))
> != APR_SUCCESS) {
> + ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "Cannot init
> worker");
> + return rv;
> + }
> + }
> + }
> + b->wupdated = b->s->wupdated;
> + return APR_SUCCESS;
> +}
> +
> static void ap_proxy_balancer_register_hook(apr_pool_t *p)
> {
> /* Only the mpm_winnt has child init hook handler.
>