MCPcopy Index your code
hub / github.com/apache/httpd / balancer_handler

Function balancer_handler

modules/proxy/mod_proxy_balancer.c:1905–2013  ·  view source on GitHub ↗

Manages the loadfactors and member status * The balancer, worker and nonce are obtained from * the request args (?b=...&w=...&nonce=....). * All other params are pulled from any POST * data that exists. * TODO: * /.../ /balancer/worker/nonce */

Source from the content-addressed store, hash-verified

1903 * /.../<whatever>/balancer/worker/nonce
1904 */
1905static int balancer_handler(request_rec *r)
1906{
1907 void *sconf;
1908 proxy_server_conf *conf;
1909 proxy_balancer *balancer, *bsel = NULL;
1910 proxy_worker *wsel = NULL;
1911 apr_table_t *params;
1912 int i;
1913 const char *name, *ref;
1914 apr_status_t rv;
1915
1916 /* is this for us? */
1917 if (strcmp(r->handler, "balancer-manager")) {
1918 return DECLINED;
1919 }
1920
1921 r->allowed = 0
1922 | (AP_METHOD_BIT << M_GET)
1923 | (AP_METHOD_BIT << M_POST);
1924 if ((r->method_number != M_GET) && (r->method_number != M_POST)) {
1925 return DECLINED;
1926 }
1927
1928 sconf = r->server->module_config;
1929 conf = (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
1930 params = apr_table_make(r->pool, 10);
1931
1932 balancer = (proxy_balancer *)conf->balancers->elts;
1933 for (i = 0; i < conf->balancers->nelts; i++, balancer++) {
1934#if APR_HAS_THREADS
1935 if ((rv = PROXY_THREAD_LOCK(balancer)) != APR_SUCCESS) {
1936 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01189)
1937 "%s: Lock failed for balancer_handler",
1938 balancer->s->name);
1939 }
1940#endif
1941 ap_proxy_sync_balancer(balancer, r->server, conf);
1942#if APR_HAS_THREADS
1943 if ((rv = PROXY_THREAD_UNLOCK(balancer)) != APR_SUCCESS) {
1944 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01190)
1945 "%s: Unlock failed for balancer_handler",
1946 balancer->s->name);
1947 }
1948#endif
1949 }
1950
1951 if (r->args && (r->method_number == M_GET)) {
1952 const char *allowed[] = { "w", "b", "nonce", "xml", NULL };
1953 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01191) "parsing r->args");
1954
1955 push2table(r->args, params, allowed, r->pool);
1956 }
1957 if (r->method_number == M_POST) {
1958 apr_bucket_brigade *ib;
1959 apr_size_t len = 1024;
1960 char *buf = apr_pcalloc(r->pool, len+1);
1961
1962 ib = apr_brigade_create(r->connection->pool, r->connection->bucket_alloc);

Callers

nothing calls this directly

Calls 11

ap_get_module_configFunction · 0.85
ap_proxy_sync_balancerFunction · 0.85
push2tableFunction · 0.85
ap_get_brigadeFunction · 0.85
safe_refererFunction · 0.85
ap_get_server_nameFunction · 0.85
ap_proxy_get_balancerFunction · 0.85
ap_proxy_get_workerFunction · 0.85
balancer_display_pageFunction · 0.85

Tested by

no test coverage detected