mod_proxy_balancer.c revision 9056fdeb30584edd8495a254901a50f62bc81979
08cb74ca432a8c24e39f17dedce527e6a47b8001jerenkrantz/* Licensed to the Apache Software Foundation (ASF) under one or more
08cb74ca432a8c24e39f17dedce527e6a47b8001jerenkrantz * contributor license agreements. See the NOTICE file distributed with
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * this work for additional information regarding copyright ownership.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * The ASF licenses this file to You under the Apache License, Version 2.0
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * (the "License"); you may not use this file except in compliance with
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * the License. You may obtain a copy of the License at
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * http://www.apache.org/licenses/LICENSE-2.0
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Unless required by applicable law or agreed to in writing, software
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * distributed under the License is distributed on an "AS IS" BASIS,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * See the License for the specific language governing permissions and
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * limitations under the License.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/* Load balancer module for Apache proxy */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#define CORE_PRIVATE
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include "mod_proxy.h"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include "ap_mpm.h"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include "apr_version.h"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include "apr_hooks.h"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#if APR_HAVE_UNISTD_H
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include <unistd.h> /* for getpid() */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#endif
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesmodule AP_MODULE_DECLARE_DATA proxy_balancer_module;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesstatic int proxy_balancer_canon(request_rec *r, char *url)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes{
5c0419d51818eb02045cf923a9fe456127a44c60wrowe char *host, *path, *search;
5c0419d51818eb02045cf923a9fe456127a44c60wrowe const char *err;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_port_t port = 0;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (strncasecmp(url, "balancer:", 9) == 0) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes url += 9;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes else {
d266c3777146d36a4c23c17aad6f153aebea1bf4jorton return DECLINED;
d266c3777146d36a4c23c17aad6f153aebea1bf4jorton }
d266c3777146d36a4c23c17aad6f153aebea1bf4jorton
d266c3777146d36a4c23c17aad6f153aebea1bf4jorton ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "proxy: BALANCER: canonicalising URL %s", url);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* do syntatic check.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * We break the URL into host, port, path, search
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes err = ap_proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (err) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "error parsing URL %s: %s",
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes url, err);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return HTTP_BAD_REQUEST;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
b6c405caec8a41b770da7466bf8c8737ef1472d7bnicholes /* now parse path/search args, according to rfc1738 */
b6c405caec8a41b770da7466bf8c8737ef1472d7bnicholes /* N.B. if this isn't a true proxy request, then the URL _path_
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * has already been decoded. True proxy requests have r->uri
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * == r->unparsed_uri, and no others have that property.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (r->uri == r->unparsed_uri) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes search = strchr(url, '?');
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (search != NULL)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *(search++) = '\0';
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes else
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes search = r->args;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* process path */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes path = ap_proxy_canonenc(r->pool, url, strlen(url), enc_path, 0, r->proxyreq);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (path == NULL)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return HTTP_BAD_REQUEST;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes r->filename = apr_pstrcat(r->pool, "proxy:balancer://", host,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "/", path, (search) ? "?" : "", (search) ? search : "", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes r->path_info = apr_pstrcat(r->pool, "/", path, NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return OK;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes}
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesstatic int init_balancer_members(proxy_server_conf *conf, server_rec *s,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_balancer *balancer)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes{
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int i;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_worker *workers;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes workers = (proxy_worker *)balancer->workers->elts;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes for (i = 0; i < balancer->workers->nelts; i++) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_proxy_initialize_worker_share(conf, workers, s);
0568280364eb026393be492ebc732795c4934643jorton ap_proxy_initialize_worker(workers, s);
0568280364eb026393be492ebc732795c4934643jorton ++workers;
0568280364eb026393be492ebc732795c4934643jorton }
0568280364eb026393be492ebc732795c4934643jorton
0568280364eb026393be492ebc732795c4934643jorton workers = (proxy_worker *)balancer->workers->elts;
0568280364eb026393be492ebc732795c4934643jorton for (i = 0; i < balancer->workers->nelts; i++) {
0568280364eb026393be492ebc732795c4934643jorton /* Set to the original configuration */
0568280364eb026393be492ebc732795c4934643jorton workers[i].s->lbstatus = workers[i].s->lbfactor =
0568280364eb026393be492ebc732795c4934643jorton (workers[i].lbfactor ? workers[i].lbfactor : 1);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes workers[i].s->lbset = workers[i].lbset;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* Set default number of attempts to the number of
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * workers.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (!balancer->max_attempts_set && balancer->workers->nelts > 1) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes balancer->max_attempts = balancer->workers->nelts - 1;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes balancer->max_attempts_set = 1;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return 0;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes}
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/* Retrieve the parameter with the given name
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Something like 'JSESSIONID=12345...N'
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesstatic char *get_path_param(apr_pool_t *pool, char *url,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes const char *name)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes{
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes char *path = NULL;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes for (path = strstr(url, name); path; path = strstr(path + 1, name)) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes path += strlen(name);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (*path == '=') {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /*
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Session path was found, get it's value
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe ++path;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (strlen(path)) {
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe char *q;
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe path = apr_strtok(apr_pstrdup(pool, path), "?&", &q);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe return path;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return NULL;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes}
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesstatic char *get_cookie_param(request_rec *r, const char *name)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes{
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes const char *cookies;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes const char *start_cookie;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((cookies = apr_table_get(r->headers_in, "Cookie"))) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes for (start_cookie = ap_strstr_c(cookies, name); start_cookie;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes start_cookie = ap_strstr_c(start_cookie + 1, name)) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (start_cookie == cookies ||
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe start_cookie[-1] == ';' ||
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe start_cookie[-1] == ',' ||
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes isspace(start_cookie[-1])) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes start_cookie += strlen(name);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes while(*start_cookie && isspace(*start_cookie))
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ++start_cookie;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (*start_cookie == '=' && start_cookie[1]) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /*
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Session cookie was found, get it's value
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes char *end_cookie, *cookie;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ++start_cookie;
f43b67c5a9d29b572eac916f8335cedc80c908bebnicholes cookie = apr_pstrdup(r->pool, start_cookie);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((end_cookie = strchr(cookie, ';')) != NULL)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *end_cookie = '\0';
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe if((end_cookie = strchr(cookie, ',')) != NULL)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *end_cookie = '\0';
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return cookie;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return NULL;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes}
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/* Find the worker that has the 'route' defined
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesstatic proxy_worker *find_route_worker(proxy_balancer *balancer,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes const char *route, request_rec *r)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes{
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int i;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int checking_standby;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int checked_standby;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_worker *worker;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes checking_standby = checked_standby = 0;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes while (!checked_standby) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes worker = (proxy_worker *)balancer->workers->elts;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes for (i = 0; i < balancer->workers->nelts; i++, worker++) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) )
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes continue;
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe if (*(worker->s->route) && strcmp(worker->s->route, route) == 0) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (worker && PROXY_WORKER_IS_USABLE(worker)) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return worker;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes } else {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /*
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * If the worker is in error state run
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * retry on that worker. It will be marked as
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * operational if the retry timeout is elapsed.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * The worker might still be unusable, but we try
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * anyway.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_proxy_retry_worker("BALANCER", worker, r->server);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (PROXY_WORKER_IS_USABLE(worker)) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return worker;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes } else {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /*
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * We have a worker that is unusable.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * It can be in error or disabled, but in case
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * it has a redirection set use that redirection worker.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * This enables to safely remove the member from the
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * balancer. Of course you will need some kind of
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe * session replication between those two remote.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (*worker->s->redirect) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_worker *rworker = NULL;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes rworker = find_route_worker(balancer, worker->s->redirect, r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* Check if the redirect worker is usable */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (rworker && !PROXY_WORKER_IS_USABLE(rworker)) {
f43b67c5a9d29b572eac916f8335cedc80c908bebnicholes /*
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * If the worker is in error state run
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * retry on that worker. It will be marked as
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * operational if the retry timeout is elapsed.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * The worker might still be unusable, but we try
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * anyway.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_proxy_retry_worker("BALANCER", rworker, r->server);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (rworker && PROXY_WORKER_IS_USABLE(rworker))
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return rworker;
f43b67c5a9d29b572eac916f8335cedc80c908bebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes checked_standby = checking_standby++;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return NULL;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes}
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesstatic proxy_worker *find_session_route(proxy_balancer *balancer,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes request_rec *r,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes char **route,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes char **url)
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe{
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe proxy_worker *worker = NULL;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
54d22ed1c429b903b029bbd62621f11a9e286137minfrin if (!balancer->sticky)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return NULL;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* Try to find the sticky route inside url */
54d22ed1c429b903b029bbd62621f11a9e286137minfrin *route = get_path_param(r->pool, *url, balancer->sticky);
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes if (!*route)
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes *route = get_cookie_param(r, balancer->sticky);
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes "proxy: BALANCER: Found value %s for "
54d22ed1c429b903b029bbd62621f11a9e286137minfrin "stickysession %s", *route, balancer->sticky);
54d22ed1c429b903b029bbd62621f11a9e286137minfrin /*
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * If we found a value for sticksession, find the first '.' within.
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * Everything after '.' (if present) is our route.
54d22ed1c429b903b029bbd62621f11a9e286137minfrin */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((*route) && ((*route = strchr(*route, '.')) != NULL ))
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes (*route)++;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((*route) && (**route)) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "proxy: BALANCER: Found route %s", *route);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* We have a route in path or in cookie
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Find the worker that has this route defined.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes worker = find_route_worker(balancer, *route, r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (worker && strcmp(*route, worker->s->route)) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /*
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Notice that the route of the worker chosen is different from
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * the route supplied by the client.
54d22ed1c429b903b029bbd62621f11a9e286137minfrin */
81965264d92dd8c9ca21d058420f6f6da34b3032minfrin apr_table_setn(r->subprocess_env, "BALANCER_ROUTE_CHANGED", "1");
81965264d92dd8c9ca21d058420f6f6da34b3032minfrin ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
81965264d92dd8c9ca21d058420f6f6da34b3032minfrin "proxy: BALANCER: Route changed from %s to %s",
81965264d92dd8c9ca21d058420f6f6da34b3032minfrin *route, worker->s->route);
54d22ed1c429b903b029bbd62621f11a9e286137minfrin }
54d22ed1c429b903b029bbd62621f11a9e286137minfrin return worker;
54d22ed1c429b903b029bbd62621f11a9e286137minfrin }
54d22ed1c429b903b029bbd62621f11a9e286137minfrin else
81965264d92dd8c9ca21d058420f6f6da34b3032minfrin return NULL;
54d22ed1c429b903b029bbd62621f11a9e286137minfrin}
e18ba90a1e610b43062e90cfa8bf0c1edcad7a49bnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesstatic proxy_worker *find_best_worker(proxy_balancer *balancer,
560fd0658902ab57754616c172d8953e69fc4722bnicholes request_rec *r)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes{
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_worker *candidate = NULL;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_status_t rv;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((rv = PROXY_THREAD_LOCK(balancer)) != APR_SUCCESS) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
54d22ed1c429b903b029bbd62621f11a9e286137minfrin "proxy: BALANCER: (%s). Lock failed for find_best_worker()", balancer->name);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return NULL;
54d22ed1c429b903b029bbd62621f11a9e286137minfrin }
54d22ed1c429b903b029bbd62621f11a9e286137minfrin
54d22ed1c429b903b029bbd62621f11a9e286137minfrin candidate = (*balancer->lbmethod->finder)(balancer, r);
54d22ed1c429b903b029bbd62621f11a9e286137minfrin
54d22ed1c429b903b029bbd62621f11a9e286137minfrin if (candidate)
54d22ed1c429b903b029bbd62621f11a9e286137minfrin candidate->s->elected++;
54d22ed1c429b903b029bbd62621f11a9e286137minfrin
54d22ed1c429b903b029bbd62621f11a9e286137minfrin/*
54d22ed1c429b903b029bbd62621f11a9e286137minfrin PROXY_THREAD_UNLOCK(balancer);
54d22ed1c429b903b029bbd62621f11a9e286137minfrin return NULL;
54d22ed1c429b903b029bbd62621f11a9e286137minfrin*/
54d22ed1c429b903b029bbd62621f11a9e286137minfrin
54d22ed1c429b903b029bbd62621f11a9e286137minfrin if ((rv = PROXY_THREAD_UNLOCK(balancer)) != APR_SUCCESS) {
54d22ed1c429b903b029bbd62621f11a9e286137minfrin ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
54d22ed1c429b903b029bbd62621f11a9e286137minfrin "proxy: BALANCER: (%s). Unlock failed for find_best_worker()", balancer->name);
54d22ed1c429b903b029bbd62621f11a9e286137minfrin }
54d22ed1c429b903b029bbd62621f11a9e286137minfrin
54d22ed1c429b903b029bbd62621f11a9e286137minfrin if (candidate == NULL) {
54d22ed1c429b903b029bbd62621f11a9e286137minfrin /* All the workers are in error state or disabled.
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * If the balancer has a timeout sleep for a while
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * and try again to find the worker. The chances are
81965264d92dd8c9ca21d058420f6f6da34b3032minfrin * that some other thread will release a connection.
e1cc1ac970d0aa2910027f1f20445a16207a6deeminfrin * By default the timeout is not set, and the server
e1cc1ac970d0aa2910027f1f20445a16207a6deeminfrin * returns SERVER_BUSY.
e1cc1ac970d0aa2910027f1f20445a16207a6deeminfrin */
e1cc1ac970d0aa2910027f1f20445a16207a6deeminfrin#if APR_HAS_THREADS
e1cc1ac970d0aa2910027f1f20445a16207a6deeminfrin if (balancer->timeout) {
e1cc1ac970d0aa2910027f1f20445a16207a6deeminfrin /* XXX: This can perhaps be build using some
e1cc1ac970d0aa2910027f1f20445a16207a6deeminfrin * smarter mechanism, like tread_cond.
e1cc1ac970d0aa2910027f1f20445a16207a6deeminfrin * But since the statuses can came from
e1cc1ac970d0aa2910027f1f20445a16207a6deeminfrin * different childs, use the provided algo.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_interval_time_t timeout = balancer->timeout;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_interval_time_t step, tval = 0;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* Set the timeout to 0 so that we don't
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * end in infinite loop
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes balancer->timeout = 0;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes step = timeout / 100;
7add8f7fb048534390571801b7794f71cd9e127abnicholes while (tval < timeout) {
7add8f7fb048534390571801b7794f71cd9e127abnicholes apr_sleep(step);
141e1368614dc7564e1627671361b01b4869b491bnicholes /* Try again */
141e1368614dc7564e1627671361b01b4869b491bnicholes if ((candidate = find_best_worker(balancer, r)))
7add8f7fb048534390571801b7794f71cd9e127abnicholes break;
7add8f7fb048534390571801b7794f71cd9e127abnicholes tval += step;
7add8f7fb048534390571801b7794f71cd9e127abnicholes }
7add8f7fb048534390571801b7794f71cd9e127abnicholes /* restore the timeout */
7add8f7fb048534390571801b7794f71cd9e127abnicholes balancer->timeout = timeout;
7add8f7fb048534390571801b7794f71cd9e127abnicholes }
7add8f7fb048534390571801b7794f71cd9e127abnicholes#endif
7add8f7fb048534390571801b7794f71cd9e127abnicholes }
7add8f7fb048534390571801b7794f71cd9e127abnicholes return candidate;
7add8f7fb048534390571801b7794f71cd9e127abnicholes}
7add8f7fb048534390571801b7794f71cd9e127abnicholes
7add8f7fb048534390571801b7794f71cd9e127abnicholesstatic int rewrite_url(request_rec *r, proxy_worker *worker,
7add8f7fb048534390571801b7794f71cd9e127abnicholes char **url)
7add8f7fb048534390571801b7794f71cd9e127abnicholes{
7add8f7fb048534390571801b7794f71cd9e127abnicholes const char *scheme = strstr(*url, "://");
7add8f7fb048534390571801b7794f71cd9e127abnicholes const char *path = NULL;
7add8f7fb048534390571801b7794f71cd9e127abnicholes
7add8f7fb048534390571801b7794f71cd9e127abnicholes if (scheme)
7add8f7fb048534390571801b7794f71cd9e127abnicholes path = ap_strchr_c(scheme + 3, '/');
7add8f7fb048534390571801b7794f71cd9e127abnicholes
7add8f7fb048534390571801b7794f71cd9e127abnicholes /* we break the URL into host, port, uri */
141e1368614dc7564e1627671361b01b4869b491bnicholes if (!worker) {
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes return ap_proxyerror(r, HTTP_BAD_REQUEST, apr_pstrcat(r->pool,
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes "missing worker. URI cannot be parsed: ", *url,
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes NULL));
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes }
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes *url = apr_pstrcat(r->pool, worker->name, path, NULL);
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes return OK;
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes}
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholesstatic void force_recovery(proxy_balancer *balancer, server_rec *s)
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes{
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes int i;
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes int ok = 0;
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes proxy_worker *worker;
3dfeb02cfb853d8717ca0cc259b59fea610173f5bnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes worker = (proxy_worker *)balancer->workers->elts;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes for (i = 0; i < balancer->workers->nelts; i++, worker++) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (!(worker->s->status & PROXY_WORKER_IN_ERROR)) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ok = 1;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes break;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (!ok) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* If all workers are in error state force the recovery.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes worker = (proxy_worker *)balancer->workers->elts;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes for (i = 0; i < balancer->workers->nelts; i++, worker++) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ++worker->s->retries;
54d22ed1c429b903b029bbd62621f11a9e286137minfrin worker->s->status &= ~PROXY_WORKER_IN_ERROR;
54d22ed1c429b903b029bbd62621f11a9e286137minfrin ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
54d22ed1c429b903b029bbd62621f11a9e286137minfrin "proxy: BALANCER: (%s). Forcing recovery for worker (%s)",
54d22ed1c429b903b029bbd62621f11a9e286137minfrin balancer->name, worker->hostname);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
54d22ed1c429b903b029bbd62621f11a9e286137minfrin }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes}
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesstatic int proxy_balancer_pre_request(proxy_worker **worker,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_balancer **balancer,
54d22ed1c429b903b029bbd62621f11a9e286137minfrin request_rec *r,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_server_conf *conf, char **url)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes{
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int access_status;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_worker *runtime;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes char *route = NULL;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_status_t rv;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *worker = NULL;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* Step 1: check if the url is for us
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * The url we can handle starts with 'balancer://'
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * If balancer is already provided skip the search
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * for balancer, because this is failover attempt.
54d22ed1c429b903b029bbd62621f11a9e286137minfrin */
54d22ed1c429b903b029bbd62621f11a9e286137minfrin if (!*balancer &&
54d22ed1c429b903b029bbd62621f11a9e286137minfrin !(*balancer = ap_proxy_get_balancer(r->pool, conf, *url)))
54d22ed1c429b903b029bbd62621f11a9e286137minfrin return DECLINED;
54d22ed1c429b903b029bbd62621f11a9e286137minfrin
54d22ed1c429b903b029bbd62621f11a9e286137minfrin /* Step 2: Lock the LoadBalancer
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * XXX: perhaps we need the process lock here
54d22ed1c429b903b029bbd62621f11a9e286137minfrin */
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe if ((rv = PROXY_THREAD_LOCK(*balancer)) != APR_SUCCESS) {
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
8a03cd420b800a2428f49f4617293de9b2387b20jorton "proxy: BALANCER: (%s). Lock failed for pre_request",
54d22ed1c429b903b029bbd62621f11a9e286137minfrin (*balancer)->name);
54d22ed1c429b903b029bbd62621f11a9e286137minfrin return DECLINED;
54d22ed1c429b903b029bbd62621f11a9e286137minfrin }
54d22ed1c429b903b029bbd62621f11a9e286137minfrin
54d22ed1c429b903b029bbd62621f11a9e286137minfrin /* Step 3: force recovery */
54d22ed1c429b903b029bbd62621f11a9e286137minfrin force_recovery(*balancer, r->server);
54d22ed1c429b903b029bbd62621f11a9e286137minfrin
54d22ed1c429b903b029bbd62621f11a9e286137minfrin /* Step 4: find the session route */
54d22ed1c429b903b029bbd62621f11a9e286137minfrin runtime = find_session_route(*balancer, r, &route, url);
54d22ed1c429b903b029bbd62621f11a9e286137minfrin if (runtime) {
54d22ed1c429b903b029bbd62621f11a9e286137minfrin int i, total_factor = 0;
54d22ed1c429b903b029bbd62621f11a9e286137minfrin proxy_worker *workers;
54d22ed1c429b903b029bbd62621f11a9e286137minfrin /* We have a sticky load balancer
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * Update the workers status
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * so that even session routes get
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * into account.
54d22ed1c429b903b029bbd62621f11a9e286137minfrin */
edc346c3223efd41e6a2057c37cea69744b73dccwrowe workers = (proxy_worker *)(*balancer)->workers->elts;
edc346c3223efd41e6a2057c37cea69744b73dccwrowe for (i = 0; i < (*balancer)->workers->nelts; i++) {
54d22ed1c429b903b029bbd62621f11a9e286137minfrin /* Take into calculation only the workers that are
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * not in error state or not disabled.
54d22ed1c429b903b029bbd62621f11a9e286137minfrin *
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * TODO: Abstract the below, since this is dependent
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * on the LB implementation
54d22ed1c429b903b029bbd62621f11a9e286137minfrin */
54d22ed1c429b903b029bbd62621f11a9e286137minfrin if (PROXY_WORKER_IS_USABLE(workers)) {
54d22ed1c429b903b029bbd62621f11a9e286137minfrin workers->s->lbstatus += workers->s->lbfactor;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes total_factor += workers->s->lbfactor;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes workers++;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes runtime->s->lbstatus -= total_factor;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes runtime->s->elected++;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe *worker = runtime;
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe }
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe else if (route && (*balancer)->sticky_force) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe "proxy: BALANCER: (%s). All workers are in error state for route (%s)",
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe (*balancer)->name, route);
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) {
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe "proxy: BALANCER: (%s). Unlock failed for pre_request",
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe (*balancer)->name);
54d22ed1c429b903b029bbd62621f11a9e286137minfrin }
560fd0658902ab57754616c172d8953e69fc4722bnicholes return HTTP_SERVICE_UNAVAILABLE;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "proxy: BALANCER: (%s). Unlock failed for pre_request",
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes (*balancer)->name);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (!*worker) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes runtime = find_best_worker(*balancer, r);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe if (!runtime) {
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "proxy: BALANCER: (%s). All workers are in error state",
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes (*balancer)->name);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return HTTP_SERVICE_UNAVAILABLE;
560fd0658902ab57754616c172d8953e69fc4722bnicholes }
560fd0658902ab57754616c172d8953e69fc4722bnicholes if ((*balancer)->sticky && runtime) {
560fd0658902ab57754616c172d8953e69fc4722bnicholes /*
560fd0658902ab57754616c172d8953e69fc4722bnicholes * This balancer has sticky sessions and the client either has not
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * supplied any routing information or all workers for this route
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * including possible redirect and hotstandby workers are in error
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * state, but we have found another working worker for this
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * balancer where we can send the request. Thus notice that we have
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * changed the route to the backend.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_table_setn(r->subprocess_env, "BALANCER_ROUTE_CHANGED", "1");
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe }
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe *worker = runtime;
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe }
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe /* Add balancer/worker info to env. */
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe apr_table_setn(r->subprocess_env,
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe "BALANCER_NAME", (*balancer)->name);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe apr_table_setn(r->subprocess_env,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "BALANCER_WORKER_NAME", (*worker)->name);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_table_setn(r->subprocess_env,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "BALANCER_WORKER_ROUTE", (*worker)->s->route);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* Rewrite the url from 'balancer://url'
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * to the 'worker_scheme://worker_hostname[:worker_port]/url'
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * This replaces the balancers fictional name with the
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * real hostname of the elected worker.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes access_status = rewrite_url(r, *worker, url);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* Add the session route to request notes if present */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (route) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_table_setn(r->notes, "session-sticky", (*balancer)->sticky);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_table_setn(r->notes, "session-route", route);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* Add session info to env. */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_table_setn(r->subprocess_env,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "BALANCER_SESSION_STICKY", (*balancer)->sticky);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_table_setn(r->subprocess_env,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "BALANCER_SESSION_ROUTE", route);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
560fd0658902ab57754616c172d8953e69fc4722bnicholes "proxy: BALANCER (%s) worker (%s) rewritten to %s",
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe (*balancer)->name, (*worker)->name, *url);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return access_status;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes}
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesstatic int proxy_balancer_post_request(proxy_worker *worker,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_balancer *balancer,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes request_rec *r,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_server_conf *conf)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes{
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#if 0
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_status_t rv;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((rv = PROXY_THREAD_LOCK(balancer)) != APR_SUCCESS) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "proxy: BALANCER: (%s). Lock failed for post_request",
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes balancer->name);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return HTTP_INTERNAL_SERVER_ERROR;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* TODO: placeholder for post_request actions
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((rv = PROXY_THREAD_UNLOCK(balancer)) != APR_SUCCESS) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "proxy: BALANCER: (%s). Unlock failed for post_request",
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes balancer->name);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "proxy_balancer_post_request for (%s)", balancer->name);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#endif
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return OK;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes}
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesstatic void recalc_factors(proxy_balancer *balancer)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes{
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int i;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_worker *workers;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* Recalculate lbfactors */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes workers = (proxy_worker *)balancer->workers->elts;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* Special case if there is only one worker it's
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * load factor will always be 1
54d22ed1c429b903b029bbd62621f11a9e286137minfrin */
54d22ed1c429b903b029bbd62621f11a9e286137minfrin if (balancer->workers->nelts == 1) {
54d22ed1c429b903b029bbd62621f11a9e286137minfrin workers->s->lbstatus = workers->s->lbfactor = 1;
54d22ed1c429b903b029bbd62621f11a9e286137minfrin return;
54d22ed1c429b903b029bbd62621f11a9e286137minfrin }
560fd0658902ab57754616c172d8953e69fc4722bnicholes for (i = 0; i < balancer->workers->nelts; i++) {
54d22ed1c429b903b029bbd62621f11a9e286137minfrin /* Update the status entries */
54d22ed1c429b903b029bbd62621f11a9e286137minfrin workers[i].s->lbstatus = workers[i].s->lbfactor;
54d22ed1c429b903b029bbd62621f11a9e286137minfrin }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes}
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/* Manages the loadfactors and member status
f43b67c5a9d29b572eac916f8335cedc80c908bebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesstatic int balancer_handler(request_rec *r)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes{
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes void *sconf = r->server->module_config;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_server_conf *conf = (proxy_server_conf *)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_get_module_config(sconf, &proxy_module);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_balancer *balancer, *bsel = NULL;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_worker *worker, *wsel = NULL;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_table_t *params = apr_table_make(r->pool, 10);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int access_status;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int i, n;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes const char *name;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* is this for us? */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (strcmp(r->handler, "balancer-manager"))
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return DECLINED;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes r->allowed = (AP_METHOD_BIT << M_GET);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (r->method_number != M_GET)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return DECLINED;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe if (r->args) {
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe char *args = apr_pstrdup(r->pool, r->args);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe char *tok, *val;
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe while (args && *args) {
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe if ((val = ap_strchr(args, '='))) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *val++ = '\0';
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((tok = ap_strchr(val, '&')))
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *tok++ = '\0';
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe /*
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe * Special case: workers are allowed path information
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((access_status = ap_unescape_url(val)) != OK)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (strcmp(args, "w") || (access_status != HTTP_NOT_FOUND))
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return access_status;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_table_setn(params, args, val);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes args = tok;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes else
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return HTTP_BAD_REQUEST;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe if ((name = apr_table_get(params, "b")))
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe bsel = ap_proxy_get_balancer(r->pool, conf,
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe apr_pstrcat(r->pool, "balancer://", name, NULL));
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((name = apr_table_get(params, "w"))) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_worker *ws;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ws = ap_proxy_get_worker(r->pool, conf, name);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (ws) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes worker = (proxy_worker *)bsel->workers->elts;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes for (n = 0; n < bsel->workers->nelts; n++) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (strcasecmp(worker->name, ws->name) == 0) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes wsel = worker;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes break;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ++worker;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* First set the params */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (bsel) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes const char *val;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((val = apr_table_get(params, "ss"))) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (strlen(val))
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes bsel->sticky = apr_pstrdup(conf->pool, val);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes else
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes bsel->sticky = NULL;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((val = apr_table_get(params, "tm"))) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int ival = atoi(val);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (ival >= 0)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes bsel->timeout = apr_time_from_sec(ival);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((val = apr_table_get(params, "fa"))) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int ival = atoi(val);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (ival >= 0)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes bsel->max_attempts = ival;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes bsel->max_attempts_set = 1;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((val = apr_table_get(params, "lm"))) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_balancer_method *provider;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes provider = ap_lookup_provider(PROXY_LBMETHOD, val, "0");
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (provider) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes bsel->lbmethod = provider;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (wsel) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes const char *val;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((val = apr_table_get(params, "lf"))) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int ival = atoi(val);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (ival >= 1 && ival <= 100) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes wsel->s->lbfactor = ival;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (bsel)
f43b67c5a9d29b572eac916f8335cedc80c908bebnicholes recalc_factors(bsel);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((val = apr_table_get(params, "wr"))) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (strlen(val) && strlen(val) < PROXY_WORKER_MAX_ROUTE_SIZ)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes strcpy(wsel->s->route, val);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe else
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *wsel->s->route = '\0';
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe }
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe if ((val = apr_table_get(params, "rr"))) {
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe if (strlen(val) && strlen(val) < PROXY_WORKER_MAX_ROUTE_SIZ)
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe strcpy(wsel->s->redirect, val);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe else
f43b67c5a9d29b572eac916f8335cedc80c908bebnicholes *wsel->s->redirect = '\0';
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((val = apr_table_get(params, "dw"))) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (!strcasecmp(val, "Disable"))
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes wsel->s->status |= PROXY_WORKER_DISABLED;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes else if (!strcasecmp(val, "Enable"))
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes wsel->s->status &= ~PROXY_WORKER_DISABLED;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ((val = apr_table_get(params, "ls"))) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int ival = atoi(val);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (ival >= 0 && ival <= 99) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes wsel->s->lbset = ival;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (apr_table_get(params, "xml")) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_set_content_type(r, "text/xml");
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("<httpd:manager xmlns:httpd=\"http://httpd.apache.org\">\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs(" <httpd:balancers>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes balancer = (proxy_balancer *)conf->balancers->elts;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes for (i = 0; i < conf->balancers->nelts; i++) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs(" <httpd:balancer>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, " <httpd:name>", balancer->name, "</httpd:name>\n", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs(" <httpd:workers>\n", r);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe worker = (proxy_worker *)balancer->workers->elts;
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe for (n = 0; n < balancer->workers->nelts; n++) {
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe ap_rputs(" <httpd:worker>\n", r);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe ap_rvputs(r, " <httpd:scheme>", worker->scheme,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "</httpd:scheme>\n", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, " <httpd:hostname>", worker->hostname,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "</httpd:hostname>\n", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rprintf(r, " <httpd:loadfactor>%d</httpd:loadfactor>\n",
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes worker->s->lbfactor);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs(" </httpd:worker>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ++worker;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs(" </httpd:workers>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs(" </httpd:balancer>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ++balancer;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs(" </httpd:balancers>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("</httpd:manager>", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes else {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_set_content_type(r, "text/html");
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs(DOCTYPE_HTML_3_2
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "<html><head><title>Balancer Manager</title></head>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("<body><h1>Load Balancer Manager for ", r);
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe ap_rvputs(r, ap_get_server_name(r), "</h1>\n\n", NULL);
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe ap_rvputs(r, "<dl><dt>Server Version: ",
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe ap_get_server_description(), "</dt>\n", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, "<dt>Server Built: ",
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_get_server_built(), "\n</dt></dl>\n", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes balancer = (proxy_balancer *)conf->balancers->elts;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes for (i = 0; i < conf->balancers->nelts; i++) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("<hr />\n<h3>LoadBalancer Status for ", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, "<a href=\"", r->uri, "?b=",
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes balancer->name + sizeof("balancer://") - 1,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "\">", NULL);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe ap_rvputs(r, balancer->name, "</a></h3>\n\n", NULL);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe ap_rputs("\n\n<table border=\"0\" style=\"text-align: left;\"><tr>"
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe "<th>StickySession</th><th>Timeout</th><th>FailoverAttempts</th><th>Method</th>"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "</tr>\n<tr>", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, "<td>", balancer->sticky, NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rprintf(r, "</td><td>%" APR_TIME_T_FMT "</td>",
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_time_sec(balancer->timeout));
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rprintf(r, "<td>%d</td>\n", balancer->max_attempts);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rprintf(r, "<td>%s</td>\n",
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes balancer->lbmethod->name);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("</table>\n<br />", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("\n\n<table border=\"0\" style=\"text-align: left;\"><tr>"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "<th>Worker URL</th>"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "<th>Route</th><th>RouteRedir</th>"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "<th>Factor</th><th>Set</th><th>Status</th>"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "<th>Elected</th><th>To</th><th>From</th>"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "</tr>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes worker = (proxy_worker *)balancer->workers->elts;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes for (n = 0; n < balancer->workers->nelts; n++) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes char fbuf[50];
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, "<tr>\n<td><a href=\"", r->uri, "?b=",
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes balancer->name + sizeof("balancer://") - 1, "&w=",
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe ap_escape_uri(r->pool, worker->name),
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe "\">", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, worker->name, "</a></td>", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, "<td>", worker->s->route, NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, "</td><td>", worker->s->redirect, NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rprintf(r, "</td><td>%d</td>", worker->s->lbfactor);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rprintf(r, "<td>%d</td><td>", worker->s->lbset);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (worker->s->status & PROXY_WORKER_DISABLED)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("Dis ", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (worker->s->status & PROXY_WORKER_IN_ERROR)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("Err ", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (worker->s->status & PROXY_WORKER_STOPPED)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("Stop ", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (worker->s->status & PROXY_WORKER_HOT_STANDBY)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("Stby ", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (PROXY_WORKER_IS_USABLE(worker))
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("Ok", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (!PROXY_WORKER_IS_INITIALIZED(worker))
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("-", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("</td>", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rprintf(r, "<td>%" APR_SIZE_T_FMT "</td><td>", worker->s->elected);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs(apr_strfsize(worker->s->transferred, fbuf), r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("</td><td>", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs(apr_strfsize(worker->s->read, fbuf), r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("</td></tr>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ++worker;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("</table>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ++balancer;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("<hr />\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (wsel && bsel) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("<h3>Edit worker settings for ", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, wsel->name, "</h3>\n", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, "<form method=\"GET\" action=\"", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, r->uri, "\">\n<dl>", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("<table><tr><td>Load factor:</td><td><input name=\"lf\" type=text ", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rprintf(r, "value=\"%d\"></td></tr>\n", wsel->s->lbfactor);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("<tr><td>LB Set:</td><td><input name=\"ls\" type=text ", r);
f43b67c5a9d29b572eac916f8335cedc80c908bebnicholes ap_rprintf(r, "value=\"%d\"></td></tr>\n", wsel->s->lbset);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("<tr><td>Route:</td><td><input name=\"wr\" type=text ", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, "value=\"", wsel->route, NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("\"></td></tr>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("<tr><td>Route Redirect:</td><td><input name=\"rr\" type=text ", r);
bb07ee33bce1a448bcc60ca43720b1ab1c413f87minfrin ap_rvputs(r, "value=\"", wsel->redirect, NULL);
bb07ee33bce1a448bcc60ca43720b1ab1c413f87minfrin ap_rputs("\"></td></tr>\n", r);
bb07ee33bce1a448bcc60ca43720b1ab1c413f87minfrin ap_rputs("<tr><td>Status:</td><td>Disabled: <input name=\"dw\" value=\"Disable\" type=radio", r);
bb07ee33bce1a448bcc60ca43720b1ab1c413f87minfrin if (wsel->s->status & PROXY_WORKER_DISABLED)
bb07ee33bce1a448bcc60ca43720b1ab1c413f87minfrin ap_rputs(" checked", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("> | Enabled: <input name=\"dw\" value=\"Enable\" type=radio", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (!(wsel->s->status & PROXY_WORKER_DISABLED))
f43b67c5a9d29b572eac916f8335cedc80c908bebnicholes ap_rputs(" checked", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("></td></tr>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("<tr><td colspan=2><input type=submit value=\"Submit\"></td></tr>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, "</table>\n<input type=hidden name=\"w\" ", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, "value=\"", ap_escape_uri(r->pool, wsel->name), "\">\n", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, "<input type=hidden name=\"b\" ", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, "value=\"", bsel->name + sizeof("balancer://") - 1,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "\">\n</form>\n", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("<hr />\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes else if (bsel) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("<h3>Edit balancer settings for ", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, bsel->name, "</h3>\n", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, "<form method=\"GET\" action=\"", NULL);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe ap_rvputs(r, r->uri, "\">\n<dl>", NULL);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe ap_rputs("<table><tr><td>StickySession Identifier:</td><td><input name=\"ss\" type=text ", r);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe if (bsel->sticky)
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe ap_rvputs(r, "value=\"", bsel->sticky, "\"", NULL);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe ap_rputs("></td><tr>\n<tr><td>Timeout:</td><td><input name=\"tm\" type=text ", r);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe ap_rprintf(r, "value=\"%" APR_TIME_T_FMT "\"></td></tr>\n",
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe apr_time_sec(bsel->timeout));
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe ap_rputs("<tr><td>Failover Attempts:</td><td><input name=\"fa\" type=text ", r);
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe ap_rprintf(r, "value=\"%d\"></td></tr>\n",
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe bsel->max_attempts);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("<tr><td>LB Method:</td><td><select name=\"lm\">", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_array_header_t *methods;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_list_provider_names_t *method;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int i;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes methods = ap_list_provider_names(r->pool, PROXY_LBMETHOD, "0");
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes method = (ap_list_provider_names_t *)methods->elts;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes for (i = 0; i < methods->nelts; i++) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rprintf(r, "<option value=\"%s\" %s>%s</option>", method->provider_name,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes (!strcasecmp(bsel->lbmethod->name, method->provider_name)) ? "selected" : "",
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes method->provider_name);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes method++;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("</select></td></tr>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("<tr><td colspan=2><input type=submit value=\"Submit\"></td></tr>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, "</table>\n<input type=hidden name=\"b\" ", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rvputs(r, "value=\"", bsel->name + sizeof("balancer://") - 1,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "\">\n</form>\n", NULL);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("<hr />\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs(ap_psignature("",r), r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_rputs("</body></html>\n", r);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe return OK;
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe}
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe
8113dac419143273351446c3ad653f3fe5ba5cfdwrowestatic void child_init(apr_pool_t *p, server_rec *s)
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe{
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes while (s) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes void *sconf = s->module_config;
8bdea88407c848c1c2693655e2f8b23abde12307bnicholes proxy_server_conf *conf;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_balancer *balancer;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int i;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes conf = (proxy_server_conf *)ap_get_module_config(sconf, &proxy_module);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* Initialize shared scoreboard data */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes balancer = (proxy_balancer *)conf->balancers->elts;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes for (i = 0; i < conf->balancers->nelts; i++) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes init_balancer_members(conf, s, balancer);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes balancer++;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes s = s->next;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes}
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/*
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * The idea behind the find_best_byrequests scheduler is the following:
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe * lbfactor is "how much we expect this worker to work", or "the worker's
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe * normalized work quota".
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * lbstatus is "how urgent this worker has to work to fulfill its quota
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * of work".
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * We distribute each worker's work quota to the worker, and then look
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * which of them needs to work most urgently (biggest lbstatus). This
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * worker is then selected for work, and its lbstatus reduced by the
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * total work quota we distributed to all workers. Thus the sum of all
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe * lbstatus does not change.(*)
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe *
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholes * If some workers are disabled, the others will
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * still be scheduled correctly.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * If a balancer is configured as follows:
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * worker a b c d
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe * lbfactor 25 25 25 25
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe *
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe * And b gets disabled, the following schedule is produced:
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * a c d a c d a c d ...
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Note that the above lbfactor setting is the *exact* same as:
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * worker a b c d
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe * lbfactor 1 1 1 1
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe *
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe * Asymmetric configurations work as one would expect. For
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe * example:
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * worker a b c d
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * lbfactor 1 1 1 2
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * would have a, b and c all handling about the same
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * amount of load with d handling twice what a or b
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * or c handles individually. So we could see:
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * b a d c d a c d b d ...
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesstatic proxy_worker *find_best_byrequests(proxy_balancer *balancer,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes request_rec *r)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes{
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int i;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int total_factor = 0;
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe proxy_worker *worker;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_worker *mycandidate = NULL;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int cur_lbset = 0;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int max_lbset = 0;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int checking_standby;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int checked_standby;
f43b67c5a9d29b572eac916f8335cedc80c908bebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "proxy: Entering byrequests for BALANCER (%s)",
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes balancer->name);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* First try to see if we have available candidate */
bb07ee33bce1a448bcc60ca43720b1ab1c413f87minfrin do {
bb07ee33bce1a448bcc60ca43720b1ab1c413f87minfrin checking_standby = checked_standby = 0;
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe while (!mycandidate && !checked_standby) {
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe worker = (proxy_worker *)balancer->workers->elts;
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe for (i = 0; i < balancer->workers->nelts; i++, worker++) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (!checking_standby) { /* first time through */
f43b67c5a9d29b572eac916f8335cedc80c908bebnicholes if (worker->s->lbset > max_lbset)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes max_lbset = worker->s->lbset;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (worker->s->lbset > cur_lbset)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes continue;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) )
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes continue;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* If the worker is in error state run
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * retry on that worker. It will be marked as
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * operational if the retry timeout is elapsed.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * The worker might still be unusable, but we try
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * anyway.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (!PROXY_WORKER_IS_USABLE(worker))
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_proxy_retry_worker("BALANCER", worker, r->server);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* Take into calculation only the workers that are
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * not in error state or not disabled.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (PROXY_WORKER_IS_USABLE(worker)) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes worker->s->lbstatus += worker->s->lbfactor;
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe total_factor += worker->s->lbfactor;
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe if (!mycandidate || worker->s->lbstatus > mycandidate->s->lbstatus)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes mycandidate = worker;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes checked_standby = checking_standby++;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes cur_lbset++;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes } while (cur_lbset <= max_lbset && !mycandidate);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (mycandidate) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes mycandidate->s->lbstatus -= total_factor;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return mycandidate;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes}
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/*
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * The idea behind the find_best_bytraffic scheduler is the following:
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholes * We know the amount of traffic (bytes in and out) handled by each
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * worker. We normalize that traffic by each workers' weight. So assuming
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * a setup as below:
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * worker a b c
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * lbfactor 1 1 3
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * the scheduler will allow worker c to handle 3 times the
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * traffic of a and b. If each request/response results in the
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * same amount of traffic, then c would be accessed 3 times as
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * often as a or b. If, for example, a handled a request that
bb07ee33bce1a448bcc60ca43720b1ab1c413f87minfrin * resulted in a large i/o bytecount, then b and c would be
bb07ee33bce1a448bcc60ca43720b1ab1c413f87minfrin * chosen more often, to even things out.
bb07ee33bce1a448bcc60ca43720b1ab1c413f87minfrin */
bb07ee33bce1a448bcc60ca43720b1ab1c413f87minfrinstatic proxy_worker *find_best_bytraffic(proxy_balancer *balancer,
bb07ee33bce1a448bcc60ca43720b1ab1c413f87minfrin request_rec *r)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes{
f43b67c5a9d29b572eac916f8335cedc80c908bebnicholes int i;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_off_t mytraffic = 0;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_off_t curmin = 0;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_worker *worker;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_worker *mycandidate = NULL;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int cur_lbset = 0;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int max_lbset = 0;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int checking_standby;
f43b67c5a9d29b572eac916f8335cedc80c908bebnicholes int checked_standby;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes "proxy: Entering bytraffic for BALANCER (%s)",
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes balancer->name);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* First try to see if we have available candidate */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes do {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes checking_standby = checked_standby = 0;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes while (!mycandidate && !checked_standby) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes worker = (proxy_worker *)balancer->workers->elts;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes for (i = 0; i < balancer->workers->nelts; i++, worker++) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (!checking_standby) { /* first time through */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (worker->s->lbset > max_lbset)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes max_lbset = worker->s->lbset;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (worker->s->lbset > cur_lbset)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes continue;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) )
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes continue;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* If the worker is in error state run
8bdea88407c848c1c2693655e2f8b23abde12307bnicholes * retry on that worker. It will be marked as
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * operational if the retry timeout is elapsed.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * The worker might still be unusable, but we try
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * anyway.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (!PROXY_WORKER_IS_USABLE(worker))
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_proxy_retry_worker("BALANCER", worker, r->server);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* Take into calculation only the workers that are
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe * not in error state or not disabled.
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (PROXY_WORKER_IS_USABLE(worker)) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes mytraffic = (worker->s->transferred/worker->s->lbfactor) +
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes (worker->s->read/worker->s->lbfactor);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes if (!mycandidate || mytraffic < curmin) {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes mycandidate = worker;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes curmin = mytraffic;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes checked_standby = checking_standby++;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes }
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes cur_lbset++;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes } while (cur_lbset <= max_lbset && !mycandidate);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes return mycandidate;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes}
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/*
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * How to add additional lbmethods:
8bdea88407c848c1c2693655e2f8b23abde12307bnicholes * 1. Create func which determines "best" candidate worker
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * (eg: find_best_bytraffic, above)
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe * 2. Register it as a provider.
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe */
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowestatic const proxy_balancer_method byrequests =
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe{
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe "byrequests",
482f676c6c19b1c5bb5cca04dad11509c1da3a4cwrowe &find_best_byrequests,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes NULL
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholes};
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholes
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholesstatic const proxy_balancer_method bytraffic =
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholes{
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholes "bytraffic",
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholes &find_best_bytraffic,
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholes NULL
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes};
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholes
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholesstatic void ap_proxy_balancer_register_hook(apr_pool_t *p)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes{
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* Only the mpm_winnt has child init hook handler.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * make sure that we are called after the mpm
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholes * initializes and after the mod_proxy
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes static const char *const aszPred[] = { "mpm_winnt.c", "mod_proxy.c", NULL};
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes /* manager handler */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_hook_handler(balancer_handler, NULL, NULL, APR_HOOK_FIRST);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_hook_child_init(child_init, aszPred, NULL, APR_HOOK_MIDDLE);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_hook_pre_request(proxy_balancer_pre_request, NULL, NULL, APR_HOOK_FIRST);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_hook_post_request(proxy_balancer_post_request, NULL, NULL, APR_HOOK_FIRST);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes proxy_hook_canon_handler(proxy_balancer_canon, NULL, NULL, APR_HOOK_FIRST);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_register_provider(p, PROXY_LBMETHOD, "bytraffic", "0", &bytraffic);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes ap_register_provider(p, PROXY_LBMETHOD, "byrequests", "0", &byrequests);
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe}
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholes
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholesmodule AP_MODULE_DECLARE_DATA proxy_balancer_module = {
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholes STANDARD20_MODULE_STUFF,
f43b67c5a9d29b572eac916f8335cedc80c908bebnicholes NULL, /* create per-directory config structure */
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholes NULL, /* merge per-directory config structures */
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholes NULL, /* create per-server config structure */
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe NULL, /* merge per-server config structures */
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe NULL, /* command apr_table_t */
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe ap_proxy_balancer_register_hook /* register hooks */
8113dac419143273351446c3ad653f3fe5ba5cfdwrowe};
03f4448f864e31ade79856ac8c264a5e6dce3b10bnicholes