mod_proxy_balancer.c revision e8a023c6d3ea9f0faa895cbc7bdd649efb8a01d6
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb/* Licensed to the Apache Software Foundation (ASF) under one or more
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * contributor license agreements. See the NOTICE file distributed with
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * this work for additional information regarding copyright ownership.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * The ASF licenses this file to You under the Apache License, Version 2.0
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * (the "License"); you may not use this file except in compliance with
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * the License. You may obtain a copy of the License at
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Unless required by applicable law or agreed to in writing, software
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * distributed under the License is distributed on an "AS IS" BASIS,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * See the License for the specific language governing permissions and
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * limitations under the License.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb/* Load balancer module for Apache proxy */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic const char *balancer_mutex_type = "proxy-balancer-shm";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic int (*ap_proxy_retry_worker_fn)(const char *proxy_function,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Register our mutex type before the config is read so we
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * can adjust the mutex settings using the Mutex directive.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic int balancer_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb rv = ap_mutex_register(pconf, balancer_mutex_type, NULL,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbextern void proxy_update_members(proxy_balancer **balancer, request_rec *r,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic int proxy_balancer_canon(request_rec *r, char *url)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb const char *err;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* TODO: offset of BALANCER_PREFIX ?? */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "canonicalising URL %s", url);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* do syntatic check.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * We break the URL into host, port, path, search
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb err = ap_proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01157)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "error parsing URL %s: %s",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * now parse path/search args, according to rfc1738:
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * process the path. With proxy-noncanon set (by
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * mod_proxy) we use the raw, unparsed uri
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb path = ap_proxy_canonenc(r->pool, url, strlen(url), enc_path, 0,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb r->filename = apr_pstrcat(r->pool, "proxy:", BALANCER_PREFIX, host,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "/", path, (search) ? "?" : "", (search) ? search : "", NULL);
a2a0abd88b19e042a3eb2a9fa1702c25ad51303dwrowestatic void init_balancer_members(apr_pool_t *p, server_rec *s,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(01158)
c3e342e5b0b9fea6617ee16d2da02c3ef2108126dougm "Looking at %s -> %s initialized?", balancer->s->name, worker->s->name);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb worker_is_initialized = PROXY_WORKER_IS_INITIALIZED(worker);
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* Set default number of attempts to the number of
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe if (!balancer->s->max_attempts_set && balancer->workers->nelts > 1) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe balancer->s->max_attempts = balancer->workers->nelts - 1;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe/* Retrieve the parameter with the given name
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * Something like 'JSESSIONID=12345...N'
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowestatic char *get_path_param(apr_pool_t *pool, char *url,
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe for (path = strstr(url, name); path; path = strstr(path + 1, name)) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * Session path was found, get its value
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe path = apr_strtok(apr_pstrdup(pool, path), pathdelims, &q);
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowestatic char *get_cookie_param(request_rec *r, const char *name)
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe const char *cookies;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe if ((cookies = apr_table_get(r->headers_in, "Cookie"))) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe for (start_cookie = ap_strstr_c(cookies, name); start_cookie;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * Session cookie was found, get its value
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe/* Find the worker that has the 'route' defined
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowestatic proxy_worker *find_route_worker(proxy_balancer *balancer,
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe for (i = 0; i < balancer->workers->nelts; i++, workers++) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) )
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe if (*(worker->s->route) && strcmp(worker->s->route, route) == 0) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * If the worker is in error state run
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * retry on that worker. It will be marked as
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * operational if the retry timeout is elapsed.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * The worker might still be unusable, but we try
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe ap_proxy_retry_worker_fn("BALANCER", worker, r->server);
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * We have a worker that is unusable.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * It can be in error or disabled, but in case
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * it has a redirection set use that redirection worker.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * This enables to safely remove the member from the
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * balancer. Of course you will need some kind of
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * session replication between those two remote.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb rworker = find_route_worker(balancer, worker->s->redirect, r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Check if the redirect worker is usable */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * If the worker is in error state run
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * retry on that worker. It will be marked as
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * operational if the retry timeout is elapsed.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * The worker might still be unusable, but we try
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_proxy_retry_worker_fn("BALANCER", rworker, r->server);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic proxy_worker *find_session_route(proxy_balancer *balancer,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb const char **sticky_used,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Try to find the sticky route inside url */
c6ed63d53853f79bf8265c434d2e25c9db8a7fd8trawick *route = get_path_param(r->pool, *url, balancer->s->sticky_path, balancer->s->scolonsep);
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01159)
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe "Found value %s for stickysession %s",
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01160)
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe "Found value %s for stickysession %s",
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * If we found a value for sticksession, find the first '.' within.
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * Everything after '.' (if present) is our route.
2f1949bb0e3c209db94c8d521cba7380b9d11421trawick if ((*route) && ((*route = strchr(*route, '.')) != NULL ))
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01161) "Found route %s", *route);
2f1949bb0e3c209db94c8d521cba7380b9d11421trawick /* We have a route in path or in cookie
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * Find the worker that has this route defined.
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * Notice that the route of the worker chosen is different from
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * the route supplied by the client.
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe apr_table_setn(r->subprocess_env, "BALANCER_ROUTE_CHANGED", "1");
2f1949bb0e3c209db94c8d521cba7380b9d11421trawick ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01162)
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe "Route changed from %s to %s",
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowestatic proxy_worker *find_best_worker(proxy_balancer *balancer,
8aefbd756763807188d2e3ce336a8680e4893066wrowe if ((rv = PROXY_THREAD_LOCK(balancer)) != APR_SUCCESS) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01163)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "%s: Lock failed for find_best_worker()",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if ((rv = PROXY_THREAD_UNLOCK(balancer)) != APR_SUCCESS) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01164)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "%s: Unlock failed for find_best_worker()",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* All the workers are in error state or disabled.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * If the balancer has a timeout sleep for a while
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * and try again to find the worker. The chances are
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * that some other thread will release a connection.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * By default the timeout is not set, and the server
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * returns SERVER_BUSY.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* XXX: This can perhaps be build using some
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * smarter mechanism, like tread_cond.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * But since the statuses can came from
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * different childs, use the provided algo.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Set the timeout to 0 so that we don't
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * end in infinite loop
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Try again */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* restore the timeout */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic int rewrite_url(request_rec *r, proxy_worker *worker,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* we break the URL into host, port, uri */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return ap_proxyerror(r, HTTP_BAD_REQUEST, apr_pstrcat(r->pool,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb *url = apr_pstrcat(r->pool, worker->s->name, path, NULL);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic void force_recovery(proxy_balancer *balancer, server_rec *s)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb for (i = 0; i < balancer->workers->nelts; i++, worker++) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Try if we can recover */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* If all workers are in error state force the recovery.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb for (i = 0; i < balancer->workers->nelts; i++, worker++) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(01165)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "%s: Forcing recovery for worker (%s)",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic int proxy_balancer_pre_request(proxy_worker **worker,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Step 1: check if the url is for us
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * The url we can handle starts with 'balancer://'
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * If balancer is already provided skip the search
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * for balancer, because this is failover attempt.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb !(*balancer = ap_proxy_get_balancer(r->pool, conf, *url, 1)))
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Step 2: Lock the LoadBalancer
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * XXX: perhaps we need the process lock here
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if ((rv = PROXY_THREAD_LOCK(*balancer)) != APR_SUCCESS) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01166)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "%s: Lock failed for pre_request", (*balancer)->s->name);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Step 3: force recovery */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Step 3.5: Update member list for the balancer */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* TODO: Implement as provider! */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Step 4: find the session route */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb runtime = find_session_route(*balancer, r, &route, &sticky, url);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if ((*balancer)->lbmethod && (*balancer)->lbmethod->updatelbstatus) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Call the LB implementation */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb (*balancer)->lbmethod->updatelbstatus(*balancer, runtime, r->server);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb else { /* Use the default one */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* We have a sticky load balancer
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Update the workers status
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * so that even session routes get
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * into account.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Take into calculation only the workers that are
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * not in error state or not disabled.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb int i, member_of = 0;
2fa5b5878e7567e2875807c3e2a2b3b0d3ef74bewrowe * We have a route provided that doesn't match the
2fa5b5878e7567e2875807c3e2a2b3b0d3ef74bewrowe * balancer name. See if the provider route is the
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * member of the same balancer in which case return 503
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (*((*workers)->s->route) && strcmp((*workers)->s->route, route) == 0) {
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01167)
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe "%s: All workers are in error state for route (%s)",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) {
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01168)
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe "%s: Unlock failed for pre_request",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01169)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "%s: Unlock failed for pre_request",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01170)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "%s: All workers are in error state",
5bb29f57ae0184d2b3c1cdf35132f8ceb011f882wrowe ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01171)
5bb29f57ae0184d2b3c1cdf35132f8ceb011f882wrowe "%s: No workers in balancer",
5bb29f57ae0184d2b3c1cdf35132f8ceb011f882wrowe * This balancer has sticky sessions and the client either has not
5bb29f57ae0184d2b3c1cdf35132f8ceb011f882wrowe * supplied any routing information or all workers for this route
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * including possible redirect and hotstandby workers are in error
6fed20de38221f6f8a60c0ab1d907f1173c443f4wrowe * state, but we have found another working worker for this
5bb29f57ae0184d2b3c1cdf35132f8ceb011f882wrowe * balancer where we can send the request. Thus notice that we have
6fed20de38221f6f8a60c0ab1d907f1173c443f4wrowe * changed the route to the backend.
6fed20de38221f6f8a60c0ab1d907f1173c443f4wrowe apr_table_setn(r->subprocess_env, "BALANCER_ROUTE_CHANGED", "1");
6fed20de38221f6f8a60c0ab1d907f1173c443f4wrowe /* Add balancer/worker info to env. */
6fed20de38221f6f8a60c0ab1d907f1173c443f4wrowe /* Rewrite the url from 'balancer://url'
6fed20de38221f6f8a60c0ab1d907f1173c443f4wrowe * to the 'worker_scheme://worker_hostname[:worker_port]/url'
6fed20de38221f6f8a60c0ab1d907f1173c443f4wrowe * This replaces the balancers fictional name with the
6fed20de38221f6f8a60c0ab1d907f1173c443f4wrowe * real hostname of the elected worker.
6fed20de38221f6f8a60c0ab1d907f1173c443f4wrowe /* Add the session route to request notes if present */
580786e253bbe2fa462fdb24af47e52e1ef3dd83wrowe /* Add session info to env. */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01172)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "%s: worker (%s) rewritten to %s",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic int proxy_balancer_post_request(proxy_worker *worker,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if ((rv = PROXY_THREAD_LOCK(balancer)) != APR_SUCCESS) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01173)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "%s: Lock failed for post_request",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01174)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "%s: Forcing recovery for worker (%s), "
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "failonstatus %d",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if ((rv = PROXY_THREAD_UNLOCK(balancer)) != APR_SUCCESS) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01175)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "%s: Unlock failed for post_request", balancer->s->name);
4fca95918a9c0ae93593806544b425d0adc2fcc3wrowe ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01176)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "proxy_balancer_post_request for (%s)", balancer->s->name);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Recalculate lbfactors */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Special case if there is only one worker its
4fca95918a9c0ae93593806544b425d0adc2fcc3wrowe * load factor will always be 1
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Update the status entries */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb proxy_server_conf *conf = (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb for (i = 0; i < conf->balancers->nelts; i++, balancer++) {
4fca95918a9c0ae93593806544b425d0adc2fcc3wrowe/* post_config hook: */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb proxy_server_conf *conf = (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* balancer_post_config() will be called twice during startup. So, don't
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * set up the static data the 1st time through. */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG) {
4fca95918a9c0ae93593806544b425d0adc2fcc3wrowe APLOG_MARK, APLOG_EMERG, 0, s, "mod_proxy must be loaded for mod_proxy_balancer");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Get slotmem setups
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb storage = ap_lookup_provider(AP_SLOTMEM_PROVIDER_GROUP, "shm",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, APLOGNO(01177)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "Failed to lookup provider 'shm' for '%s': is "
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "mod_slotmem_shm loaded??",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Go thru each Vhost and create the shared mem slotmem for
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * each balancer's workers
2fa5b5878e7567e2875807c3e2a2b3b0d3ef74bewrowe while (s) {
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe conf = (proxy_server_conf *)ap_get_module_config(sconf, &proxy_module);
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe conf->max_balancers = conf->balancers->nelts + conf->bgrowth;
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(01178) "Doing balancers create: %d, %d (%d)",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, APLOGNO(01179) "balancer slotmem_create failed");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Initialize shared scoreboard data */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb for (i = 0; i < conf->balancers->nelts; i++, balancer++) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb unsigned int index;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb balancer->max_workers = balancer->workers->nelts + balancer->growth;
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* Create global mutex */
8aefbd756763807188d2e3ce336a8680e4893066wrowe rv = ap_global_mutex_create(&(balancer->gmutex), NULL, balancer_mutex_type,
8aefbd756763807188d2e3ce336a8680e4893066wrowe ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, APLOGNO(01180)
8aefbd756763807188d2e3ce336a8680e4893066wrowe "mutex creation of %s : %s failed", balancer_mutex_type,
8aefbd756763807188d2e3ce336a8680e4893066wrowe apr_pool_cleanup_register(pconf, (void *)s, lock_remove,
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* setup shm for balancers */
8aefbd756763807188d2e3ce336a8680e4893066wrowe if ((rv = storage->grab(conf->bslot, &index)) != APR_SUCCESS) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, APLOGNO(01181) "balancer slotmem_grab failed");
8aefbd756763807188d2e3ce336a8680e4893066wrowe if ((rv = storage->dptr(conf->bslot, index, (void *)&bshm)) != APR_SUCCESS) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, APLOGNO(01182) "balancer slotmem_dptr failed");
2fa5b5878e7567e2875807c3e2a2b3b0d3ef74bewrowe if ((rv = ap_proxy_share_balancer(balancer, bshm, index)) != APR_SUCCESS) {
2fa5b5878e7567e2875807c3e2a2b3b0d3ef74bewrowe ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, APLOGNO(01183) "Cannot share balancer");
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* create slotmem slots for workers */
8aefbd756763807188d2e3ce336a8680e4893066wrowe ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(01184) "Doing workers create: %s (%s), %d, %d",
a8d11d78181478da6a672f7fbc58b8d523351f49wrowe balancer->max_workers, AP_SLOTMEM_TYPE_PREGRAB, pconf);
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, APLOGNO(01185) "worker slotmem_create failed");
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe /* sync all timestamps */
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* now go thru each worker */
8aefbd756763807188d2e3ce336a8680e4893066wrowe for (j = 0; j < balancer->workers->nelts; j++, workers++) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe if ((rv = storage->grab(balancer->wslot, &index)) != APR_SUCCESS) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, APLOGNO(01186) "worker slotmem_grab failed");
8aefbd756763807188d2e3ce336a8680e4893066wrowe if ((rv = storage->dptr(balancer->wslot, index, (void *)&shm)) != APR_SUCCESS) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, APLOGNO(01187) "worker slotmem_dptr failed");
8aefbd756763807188d2e3ce336a8680e4893066wrowe if ((rv = ap_proxy_share_worker(worker, shm, index)) != APR_SUCCESS) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, APLOGNO(01188) "Cannot share worker");
a8d11d78181478da6a672f7fbc58b8d523351f49wrowestatic void create_radio(const char *name, unsigned int flag, request_rec *r)
a8d11d78181478da6a672f7fbc58b8d523351f49wrowe ap_rvputs(r, "<td>On <input name='", name, "' id='", name, "' value='1' type=radio", NULL);
8aefbd756763807188d2e3ce336a8680e4893066wrowe ap_rvputs(r, "> <br/> Off <input name='", name, "' id='", name, "' value='0' type=radio", NULL);
8aefbd756763807188d2e3ce336a8680e4893066wrowestatic void push2table(const char *input, apr_table_t *params,
8aefbd756763807188d2e3ce336a8680e4893066wrowe/* Manages the loadfactors and member status
4fca95918a9c0ae93593806544b425d0adc2fcc3wrowe * The balancer, worker and nonce are obtained from
4fca95918a9c0ae93593806544b425d0adc2fcc3wrowe * the request args (?b=...&w=...&nonce=....).
4fca95918a9c0ae93593806544b425d0adc2fcc3wrowe * All other params are pulled from any POST
4fca95918a9c0ae93593806544b425d0adc2fcc3wrowe * data that exists.
8aefbd756763807188d2e3ce336a8680e4893066wrowe * /.../<whatever>/balancer/worker/nonce
8aefbd756763807188d2e3ce336a8680e4893066wrowe const char *name;
8aefbd756763807188d2e3ce336a8680e4893066wrowe const char *action;
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe /* is this for us? */
8aefbd756763807188d2e3ce336a8680e4893066wrowe if ((r->method_number != M_GET) && (r->method_number != M_POST)) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe conf = (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
8aefbd756763807188d2e3ce336a8680e4893066wrowe for (i = 0; i < conf->balancers->nelts; i++, balancer++) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe if ((rv = PROXY_THREAD_LOCK(balancer)) != APR_SUCCESS) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01189)
8aefbd756763807188d2e3ce336a8680e4893066wrowe "%s: Lock failed for balancer_handler",
8aefbd756763807188d2e3ce336a8680e4893066wrowe if ((rv = PROXY_THREAD_UNLOCK(balancer)) != APR_SUCCESS) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01190)
8aefbd756763807188d2e3ce336a8680e4893066wrowe "%s: Unlock failed for balancer_handler",
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01191) "parsing r->args");
8aefbd756763807188d2e3ce336a8680e4893066wrowe ib = apr_brigade_create(r->connection->pool, r->connection->bucket_alloc);
8aefbd756763807188d2e3ce336a8680e4893066wrowe rv = ap_get_brigade(r->input_filters, ib, AP_MODE_READBYTES,
8aefbd756763807188d2e3ce336a8680e4893066wrowe apr_pstrcat(r->pool, BALANCER_PREFIX, name, NULL), 0);
8aefbd756763807188d2e3ce336a8680e4893066wrowe wsel = ap_proxy_get_worker(r->pool, bsel, conf, name);
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* Check that the supplied nonce matches this server's nonce;
8aefbd756763807188d2e3ce336a8680e4893066wrowe * otherwise ignore all parameters, to prevent a CSRF attack. */
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* First set the params */
8aefbd756763807188d2e3ce336a8680e4893066wrowe const char *val;
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01192) "settings worker params");
8aefbd756763807188d2e3ce336a8680e4893066wrowe if (strlen(val) && strlen(val) < sizeof(wsel->s->route))
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe if (strlen(val) && strlen(val) < sizeof(wsel->s->redirect))
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* if enabling, we need to reset all lb params */
8aefbd756763807188d2e3ce336a8680e4893066wrowe if (bsel && !was_usable && PROXY_WORKER_IS_USABLE(wsel)) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe const char *val;
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01193)
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe "settings balancer params");
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe lbmethod = ap_lookup_provider(PROXY_LBMETHOD, val, "0");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb nworker = ap_proxy_get_worker(conf->pool, bsel, conf, val);
948096a99010fccf648814fecf38f75c689172d7wrowe ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01194)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "%s: Lock failed for adding worker",
948096a99010fccf648814fecf38f75c689172d7wrowe ret = ap_proxy_define_worker(conf->pool, &nworker, bsel, conf, val, 0);
948096a99010fccf648814fecf38f75c689172d7wrowe unsigned int index;
948096a99010fccf648814fecf38f75c689172d7wrowe if ((rv = storage->grab(bsel->wslot, &index)) != APR_SUCCESS) {
948096a99010fccf648814fecf38f75c689172d7wrowe ap_log_rerror(APLOG_MARK, APLOG_EMERG, rv, r, APLOGNO(01195)
948096a99010fccf648814fecf38f75c689172d7wrowe "worker slotmem_grab failed");
948096a99010fccf648814fecf38f75c689172d7wrowe if ((rv = PROXY_GLOBAL_UNLOCK(bsel)) != APR_SUCCESS) {
948096a99010fccf648814fecf38f75c689172d7wrowe ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01196)
948096a99010fccf648814fecf38f75c689172d7wrowe "%s: Unlock failed for adding worker",
948096a99010fccf648814fecf38f75c689172d7wrowe if ((rv = storage->dptr(bsel->wslot, index, (void *)&shm)) != APR_SUCCESS) {
948096a99010fccf648814fecf38f75c689172d7wrowe ap_log_rerror(APLOG_MARK, APLOG_EMERG, rv, r, APLOGNO(01197)
948096a99010fccf648814fecf38f75c689172d7wrowe "worker slotmem_dptr failed");
948096a99010fccf648814fecf38f75c689172d7wrowe if ((rv = PROXY_GLOBAL_UNLOCK(bsel)) != APR_SUCCESS) {
948096a99010fccf648814fecf38f75c689172d7wrowe ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01198)
948096a99010fccf648814fecf38f75c689172d7wrowe "%s: Unlock failed for adding worker",
948096a99010fccf648814fecf38f75c689172d7wrowe if ((rv = ap_proxy_share_worker(nworker, shm, index)) != APR_SUCCESS) {
948096a99010fccf648814fecf38f75c689172d7wrowe ap_log_rerror(APLOG_MARK, APLOG_EMERG, rv, r, APLOGNO(01199)
948096a99010fccf648814fecf38f75c689172d7wrowe "Cannot share worker");
948096a99010fccf648814fecf38f75c689172d7wrowe if ((rv = PROXY_GLOBAL_UNLOCK(bsel)) != APR_SUCCESS) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01200)
3f5b4558f5410fdac5d6feed7aab0c3668f9cd13wrowe "%s: Unlock failed for adding worker",
3f5b4558f5410fdac5d6feed7aab0c3668f9cd13wrowe if ((rv = ap_proxy_initialize_worker(nworker, r->server, conf->pool)) != APR_SUCCESS) {
3f5b4558f5410fdac5d6feed7aab0c3668f9cd13wrowe ap_log_rerror(APLOG_MARK, APLOG_EMERG, rv, r, APLOGNO(01201)
948096a99010fccf648814fecf38f75c689172d7wrowe "Cannot init worker");
948096a99010fccf648814fecf38f75c689172d7wrowe if ((rv = PROXY_GLOBAL_UNLOCK(bsel)) != APR_SUCCESS) {
948096a99010fccf648814fecf38f75c689172d7wrowe ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01202)
053497224246c4dbef9af594cacf5c00ed271e6cwrowe "%s: Unlock failed for adding worker",
948096a99010fccf648814fecf38f75c689172d7wrowe /* sync all timestamps */
948096a99010fccf648814fecf38f75c689172d7wrowe bsel->wupdated = bsel->s->wupdated = nworker->s->updated = apr_time_now();
948096a99010fccf648814fecf38f75c689172d7wrowe /* by default, all new workers are disabled */
948096a99010fccf648814fecf38f75c689172d7wrowe if ((rv = PROXY_GLOBAL_UNLOCK(bsel)) != APR_SUCCESS) {
948096a99010fccf648814fecf38f75c689172d7wrowe ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01203)
948096a99010fccf648814fecf38f75c689172d7wrowe "%s: Unlock failed for adding worker",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01204) "genning page");
948096a99010fccf648814fecf38f75c689172d7wrowe ap_rputs("<?xml version='1.0' encoding='UTF-8' ?>\n", r);
948096a99010fccf648814fecf38f75c689172d7wrowe ap_rputs("<httpd:manager xmlns:httpd='http://httpd.apache.org'>\n", r);
948096a99010fccf648814fecf38f75c689172d7wrowe ap_rvputs(r, " <httpd:name>", balancer->s->name, "</httpd:name>\n", NULL);
948096a99010fccf648814fecf38f75c689172d7wrowe ap_rvputs(r, " <httpd:hostname>", worker->s->hostname,
948096a99010fccf648814fecf38f75c689172d7wrowe ap_rprintf(r, " <httpd:loadfactor>%d</httpd:loadfactor>\n",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_set_content_type(r, "text/html; charset=ISO-8859-1");
053497224246c4dbef9af594cacf5c00ed271e6cwrowe "<html><head><title>Balancer Manager</title>\n", r);
053497224246c4dbef9af594cacf5c00ed271e6cwrowe "table {\n"
053497224246c4dbef9af594cacf5c00ed271e6cwrowe " border-width: 1px;\n"
053497224246c4dbef9af594cacf5c00ed271e6cwrowe " border-spacing: 3px;\n"
053497224246c4dbef9af594cacf5c00ed271e6cwrowe " border-style: solid;\n"
053497224246c4dbef9af594cacf5c00ed271e6cwrowe " border-color: gray;\n"
948096a99010fccf648814fecf38f75c689172d7wrowe " border-collapse: collapse;\n"
948096a99010fccf648814fecf38f75c689172d7wrowe " background-color: white;\n"
053497224246c4dbef9af594cacf5c00ed271e6cwrowe " text-align: center;\n"
053497224246c4dbef9af594cacf5c00ed271e6cwrowe " border-width: 1px;\n"
053497224246c4dbef9af594cacf5c00ed271e6cwrowe " padding: 2px;\n"
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb " border-style: dotted;\n"
948096a99010fccf648814fecf38f75c689172d7wrowe " border-color: gray;\n"
948096a99010fccf648814fecf38f75c689172d7wrowe " background-color: white;\n"
948096a99010fccf648814fecf38f75c689172d7wrowe " text-align: center;\n"
948096a99010fccf648814fecf38f75c689172d7wrowe " border-width: 1px;\n"
948096a99010fccf648814fecf38f75c689172d7wrowe " padding: 2px;\n"
948096a99010fccf648814fecf38f75c689172d7wrowe " border-style: dotted;\n"
948096a99010fccf648814fecf38f75c689172d7wrowe " border-color: gray;\n"
948096a99010fccf648814fecf38f75c689172d7wrowe " background-color: white;\n"
948096a99010fccf648814fecf38f75c689172d7wrowe " text-align: center;\n"
948096a99010fccf648814fecf38f75c689172d7wrowe "</style>\n</head>\n", r);
948096a99010fccf648814fecf38f75c689172d7wrowe ap_rvputs(r, ap_get_server_name(r), "</h1>\n\n", NULL);
053497224246c4dbef9af594cacf5c00ed271e6cwrowe "<th>MaxMembers</th><th>StickySession</th><th>DisableFailover</th><th>Timeout</th><th>FailoverAttempts</th><th>Method</th>"
948096a99010fccf648814fecf38f75c689172d7wrowe "<th>Path</th><th>Active</th></tr>\n<tr>", r);
948096a99010fccf648814fecf38f75c689172d7wrowe /* the below is a safe cast, since the number of slots total will
053497224246c4dbef9af594cacf5c00ed271e6cwrowe * never be more than max_workers, which is restricted to int */
053497224246c4dbef9af594cacf5c00ed271e6cwrowe ap_rprintf(r, "<td>%d [%d Used]</td>\n", balancer->max_workers,
948096a99010fccf648814fecf38f75c689172d7wrowe balancer->max_workers - (int)storage->num_free_slots(balancer->wslot));
053497224246c4dbef9af594cacf5c00ed271e6cwrowe if (strcmp(balancer->s->sticky, balancer->s->sticky_path)) {
2fa5b5878e7567e2875807c3e2a2b3b0d3ef74bewrowe ap_rprintf(r, "<td>%d</td>\n", balancer->s->max_attempts);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "<th>Worker URL</th>"
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "<th>Route</th><th>RouteRedir</th>"
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "<th>Factor</th><th>Set</th><th>Status</th>"
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "<th>Elected</th><th>Busy</th><th>Load</th><th>To</th><th>From</th>"
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "</tr>\n", r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rvputs(r, "<td>", ap_escape_html(r->pool, worker->s->route),
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rvputs(r, ap_proxy_parse_wstatus(r->pool, worker), NULL);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rprintf(r, "<td>%" APR_SIZE_T_FMT "</td>", worker->s->elected);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rprintf(r, "<td>%" APR_SIZE_T_FMT "</td>", worker->s->busy);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rputs(apr_strfsize(worker->s->transferred, fbuf), r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rputs("<form method='POST' enctype='application/x-www-form-urlencoded' action='", r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rputs("<dl>\n<table><tr><td>Load factor:</td><td><input name='w_lf' id='w_lf' type=text ", r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rprintf(r, "value='%d'></td></tr>\n", wsel->s->lbfactor);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rputs("<tr><td>LB Set:</td><td><input name='w_ls' id='w_ls' type=text ", r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rprintf(r, "value='%d'></td></tr>\n", wsel->s->lbset);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rputs("<tr><td>Route:</td><td><input name='w_wr' id='w_wr' type=text ", r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rvputs(r, "value='", ap_escape_html(r->pool, wsel->s->route),
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rputs("<tr><td>Route Redirect:</td><td><input name='w_rr' id='w_rr' type=text ", r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rvputs(r, "value='", ap_escape_html(r->pool, wsel->s->redirect),
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rputs("<td><table><tr><th>Ign</th><th>Drn</th><th>Dis</th><th>Stby</th></tr>\n<tr>", r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb create_radio("w_status_I", (PROXY_WORKER_IGNORE_ERRORS & wsel->s->status), r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb create_radio("w_status_N", (PROXY_WORKER_DRAIN & wsel->s->status), r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb create_radio("w_status_D", (PROXY_WORKER_DISABLED & wsel->s->status), r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb create_radio("w_status_H", (PROXY_WORKER_HOT_STANDBY & wsel->s->status), r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rputs("<tr><td colspan=2><input type=submit value='Submit'></td></tr>\n", r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rvputs(r, "</table>\n<input type=hidden name='w' id='w' ", NULL);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rvputs(r, "value='", ap_escape_uri(r->pool, wsel->s->name), "'>\n", NULL);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rvputs(r, "<input type=hidden name='b' id='b' ", NULL);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rvputs(r, "value='", bsel->s->name + sizeof(BALANCER_PREFIX) - 1,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rvputs(r, "<input type=hidden name='nonce' id='nonce' value='",
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe } else if (bsel) {
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe ap_rputs("<form method='POST' enctype='application/x-www-form-urlencoded' action='", r);
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe provs = ap_list_provider_names(r->pool, PROXY_LBMETHOD, "0");
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe ap_rputs("<td>\n<select name='b_lbm' id='b_lbm'>", r);
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe ap_rvputs(r,"<option value='", pname->provider_name, "'", NULL);
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe if (strcmp(pname->provider_name, bsel->s->lbpname) == 0)
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe ap_rputs("<tr><td>Timeout:</td><td><input name='b_tmo' id='b_tmo' type=text ", r);
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe ap_rprintf(r, "value='%" APR_TIME_T_FMT "'></td></tr>\n", apr_time_sec(bsel->s->timeout));
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe ap_rputs("<tr><td>Failover Attempts:</td><td><input name='b_max' id='b_max' type=text ", r);
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe ap_rprintf(r, "value='%d'></td></tr>\n", bsel->s->max_attempts);
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe ap_rputs("<tr><td>Sticky Session:</td><td><input name='b_ss' id='b_ss' size=64 type=text ", r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rputs("'> (Use '-' to delete)</td></tr>\n", r);
4ca6cbe768b4e0917ac0b76333c26a7d5396d454trawick ap_rputs("<tr><td>Add New Worker:</td><td><input name='b_nwrkr' id='b_nwrkr' size=32 type=text>"
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb " Are you sure? <input name='b_wyes' id='b_wyes' type=checkbox value='1'>"
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "</td></tr>", r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rputs("<tr><td colspan=2><input type=submit value='Submit'></td></tr>\n", r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rvputs(r, "</table>\n<input type=hidden name='b' id='b' ", NULL);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rvputs(r, "value='", bsel->s->name + sizeof(BALANCER_PREFIX) - 1,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_rvputs(r, "<input type=hidden name='nonce' id='nonce' value='",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic void balancer_child_init(apr_pool_t *p, server_rec *s)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb while (s) {
b67fb549910fa0faf4cdd8aeaf9aeab51d4b6a92wrowe proxy_server_conf *conf = (proxy_server_conf *)ap_get_module_config(sconf, &proxy_module);
b67fb549910fa0faf4cdd8aeaf9aeab51d4b6a92wrowe unsigned int num;
b67fb549910fa0faf4cdd8aeaf9aeab51d4b6a92wrowe storage->attach(&(conf->bslot), conf->id, &size, &num, p);
b67fb549910fa0faf4cdd8aeaf9aeab51d4b6a92wrowe ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, APLOGNO(01205) "slotmem_attach failed");
b45c1c292ff1fa635004ae81fa691f8cb3cdda85rbb for (i = 0; i < conf->balancers->nelts; i++, balancer++) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, APLOGNO(01206)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "Failed to init balancer %s in child",
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowestatic void ap_proxy_balancer_register_hook(apr_pool_t *p)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Only the mpm_winnt has child init hook handler.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * make sure that we are called after the mpm
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * initializes
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb static const char *const aszPred[] = { "mpm_winnt.c", "mod_slotmem_shm.c", NULL};
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* manager handler */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_hook_post_config(balancer_post_config, NULL, NULL, APR_HOOK_MIDDLE);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_hook_pre_config(balancer_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_hook_handler(balancer_handler, NULL, NULL, APR_HOOK_FIRST);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_hook_child_init(balancer_child_init, aszPred, NULL, APR_HOOK_MIDDLE);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb proxy_hook_pre_request(proxy_balancer_pre_request, NULL, NULL, APR_HOOK_FIRST);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb proxy_hook_post_request(proxy_balancer_post_request, NULL, NULL, APR_HOOK_FIRST);