}
}
else {
- int adding = 0;
proxy_worker *worker = ap_proxy_get_worker(cmd->temp_pool, conf, r);
if (!worker) {
const char *err = ap_proxy_add_worker(&worker, cmd->pool, conf, r);
if (err)
return apr_pstrcat(cmd->temp_pool, "ProxyPass ", err, NULL);
- adding = 1;
} else {
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server,
"worker %s already used by another worker", worker->name);
if (err)
return apr_pstrcat(cmd->temp_pool, "ProxyPass ", err, NULL);
}
-
- /* XXX: ProxyPass is not a good name look for Location? */
- if (adding)
- proxy_checkstorage_add_entry(worker, "ProxyPass");
}
return NULL;
}
const apr_array_header_t *arr;
const apr_table_entry_t *elts;
int i;
- int adding = 0;
if (cmd->path)
path = apr_pstrdup(cmd->pool, cmd->path);
const char *err;
if ((err = ap_proxy_add_worker(&worker, cmd->pool, conf, name)) != NULL)
return apr_pstrcat(cmd->temp_pool, "BalancerMember ", err, NULL);
- adding = 1;
} else {
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server,
"worker %s already used by another worker", worker->name);
}
/* Add the worker to the load balancer */
ap_proxy_add_worker_to_balancer(cmd->pool, balancer, worker);
- /* XXX: Holy cow: The worker can belong to more that one balancer! */
- if (adding)
- proxy_checkstorage_add_entry(worker, balancer->name);
return NULL;
}
/* if we have a memory provider create the comarea here */
proxy_create_comarea(pconf);
+ /* Also fill the comarea of the health-checker */
+ proxy_checkstorage_add_workers(pconf, s);
+
return OK;
}
/* proxy_util.c */
-PROXY_DECLARE(void) proxy_checkstorage_add_entry(proxy_worker *worker, const char *balancer_name);
PROXY_DECLARE(void) proxy_create_comarea(apr_pool_t *pconf);
+PROXY_DECLARE(void) proxy_checkstorage_add_workers(apr_pool_t *pconf, server_rec *s);
PROXY_DECLARE(void) proxy_lookup_storage_provider();
PROXY_DECLARE(request_rec *)ap_proxy_make_fake_req(conn_rec *c, request_rec *r);
checkstorage = ap_lookup_provider(PROXY_CKMETHOD, "default", "0");
}
-/* Store the worker information in the comarea */
-PROXY_DECLARE(void) proxy_checkstorage_add_entry(proxy_worker *worker, const char *balancer_name)
+/* Copy all the worker information in the comarea */
+PROXY_DECLARE(void) proxy_checkstorage_add_workers(apr_pool_t *pconf, server_rec *s)
{
if (checkstorage) {
- checkstorage->add_entry(worker, balancer_name, worker->id);
+ while (s) {
+ void *sconf = s->module_config;
+ proxy_server_conf *conf;
+ proxy_worker *worker;
+ proxy_balancer *balancer;
+ int i, j, k;
+
+ conf = (proxy_server_conf *)ap_get_module_config(sconf, &proxy_module);
+ worker = (proxy_worker *) conf->workers->elts;
+ for (i = 0; i < conf->workers->nelts; i++) {
+ const char *name = NULL;
+ /* find the balancer if any */
+ balancer = (proxy_balancer *)conf->balancers->elts;
+ for (j = 0; j< conf->balancers->nelts; j++) {
+ proxy_worker *myworker = (proxy_worker *)balancer->workers->elts;
+ for (k = 0; k < balancer->workers->nelts; k++) {
+ if (myworker->id == worker->id) {
+ name = balancer->name;
+ break;
+ }
+ myworker++;
+ }
+ if (name)
+ break;
+ }
+
+ if (!name) {
+ /* No balancer */
+ name = "None";
+ }
+ checkstorage->add_entry(worker, name, worker->id);
+ worker++;
+ }
+
+ /* XXX: Do we need something for reverse and forward */
+
+ s = s->next;
+ }
}
}