Skip to content

Commit 08490d8

Browse files
committed
Add balancer_manage() to allow external module to fill workers for balancers.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1887176 13f79535-47bb-0310-9956-ffa450edef68
1 parent 899096a commit 08490d8

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

modules/proxy/mod_proxy_balancer.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,42 @@ static int balancer_process_balancer_worker(request_rec *r, proxy_server_conf *c
13751375
return APR_SUCCESS;
13761376
}
13771377

1378+
/*
1379+
* Process a request for balancer or worker management from another module
1380+
*/
1381+
static int balancer_manage(request_rec *r, apr_table_t *params)
1382+
{
1383+
void *sconf;
1384+
proxy_server_conf *conf;
1385+
proxy_balancer *bsel = NULL;
1386+
proxy_worker *wsel = NULL;
1387+
const char *name;
1388+
sconf = r->server->module_config;
1389+
conf = (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
1390+
1391+
/* Process the parameters */
1392+
if ((name = apr_table_get(params, "b"))) {
1393+
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "balancer_manage "
1394+
"balancer: %s", name);
1395+
bsel = ap_proxy_get_balancer(r->pool, conf,
1396+
apr_pstrcat(r->pool, BALANCER_PREFIX, name, NULL), 0);
1397+
}
1398+
1399+
if ((name = apr_table_get(params, "w"))) {
1400+
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "balancer_manage "
1401+
"worker: %s", name);
1402+
wsel = ap_proxy_get_worker(r->pool, bsel, conf, name);
1403+
}
1404+
if (bsel) {
1405+
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "balancer_manage "
1406+
"balancer: %s", bsel->s->name);
1407+
return(balancer_process_balancer_worker(r, conf, bsel, wsel, params));
1408+
}
1409+
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "balancer_manage failed: "
1410+
"No balancer!");
1411+
return HTTP_BAD_REQUEST;
1412+
}
1413+
13781414
/*
13791415
* builds the page and links to configure via HTLM or XML.
13801416
*/
@@ -2024,6 +2060,7 @@ static void ap_proxy_balancer_register_hook(apr_pool_t *p)
20242060
static const char *const aszPred[] = { "mpm_winnt.c", "mod_slotmem_shm.c", NULL};
20252061
static const char *const aszPred2[] = { "mod_proxy.c", NULL};
20262062
/* manager handler */
2063+
ap_register_provider(p, "balancer", "manager", "0", &balancer_manage);
20272064
ap_hook_post_config(balancer_post_config, aszPred2, NULL, APR_HOOK_MIDDLE);
20282065
ap_hook_pre_config(balancer_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
20292066
ap_hook_handler(balancer_handler, NULL, NULL, APR_HOOK_FIRST);

0 commit comments

Comments
 (0)