mod_proxy_balancer.c revision 25332c5e47c170ce24decd245ff37b36ec7499da
842ae4bd224140319ae7feec1872b93dfd491143fielding/* Licensed to the Apache Software Foundation (ASF) under one or more
842ae4bd224140319ae7feec1872b93dfd491143fielding * contributor license agreements. See the NOTICE file distributed with
842ae4bd224140319ae7feec1872b93dfd491143fielding * this work for additional information regarding copyright ownership.
842ae4bd224140319ae7feec1872b93dfd491143fielding * The ASF licenses this file to You under the Apache License, Version 2.0
842ae4bd224140319ae7feec1872b93dfd491143fielding * (the "License"); you may not use this file except in compliance with
842ae4bd224140319ae7feec1872b93dfd491143fielding * the License. You may obtain a copy of the License at
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * Unless required by applicable law or agreed to in writing, software
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * distributed under the License is distributed on an "AS IS" BASIS,
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * See the License for the specific language governing permissions and
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * limitations under the License.
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh/* Load balancer module for Apache proxy */
972ea41a3c47d92850a012eda961e620f339085dstoddardmodule AP_MODULE_DECLARE_DATA proxy_balancer_module;
6ccc80786ac79c81965d9df753c1c19104954a95rbbstatic char balancer_nonce[APR_UUID_FORMATTED_LENGTH + 1];
57825c3cebfc933b8c61a590e3d85e57c366723cwroweextern void proxy_update_members(proxy_balancer **balancer, request_rec *r,
d3a63226186427a5b60a39522baf37a6268bedb3wrowestatic int proxy_balancer_canon(request_rec *r, char *url)
57825c3cebfc933b8c61a590e3d85e57c366723cwrowe const char *err;
57825c3cebfc933b8c61a590e3d85e57c366723cwrowe /* do syntatic check.
742318b93e89c311f66b55f426c4d9cf2c14628bjim * We break the URL into host, port, path, search
57825c3cebfc933b8c61a590e3d85e57c366723cwrowe err = ap_proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
d489e5a735dfe88b745f4d483bbfad64bf541ae6wrowe "error parsing URL %s: %s",
00e61953c54195a57bad211f03d5b5201af0bb7ewrowe * now parse path/search args, according to rfc1738:
00e61953c54195a57bad211f03d5b5201af0bb7ewrowe * process the path. With proxy-noncanon set (by
ce1a407a85185bb48f491a75d424712418f054b6trawick * mod_proxy) we use the raw, unparsed uri
f66dbe5769a986a28d980427d890483e62232841wrowe path = ap_proxy_canonenc(r->pool, url, strlen(url), enc_path, 0,
078e29598661115f6fb037383a97c15801859357trawick r->filename = apr_pstrcat(r->pool, "proxy:balancer://", host,
57825c3cebfc933b8c61a590e3d85e57c366723cwrowe "/", path, (search) ? "?" : "", (search) ? search : "", NULL);
2fc383efaba946095813dbe3e3f11db56d0fa525stoddardstatic int init_balancer_members(proxy_server_conf *conf, server_rec *s,
bd6f55fcc632c166165842eb23dcc1105ddde364sf worker_is_initialized = PROXY_WORKER_IS_INITIALIZED(*workers);
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * If the worker is not initialized check whether its scoreboard
if (slot) {
if (!worker_is_initialized) {
++workers;
if (scolon_sep) {
++path;
if (*path) {
return path;
return NULL;
const char *cookies;
const char *start_cookie;
++start_cookie;
++start_cookie;
return cookie;
return NULL;
int checking_standby;
int checked_standby;
while (!checked_standby) {
return worker;
return worker;
return rworker;
return NULL;
request_rec *r,
char **route,
const char **sticky_used,
char **url)
return NULL;
if (*route) {
if (*route) {
(*route)++;
return worker;
return NULL;
request_rec *r)
return NULL;
if (candidate)
#if APR_HAS_THREADS
return candidate;
char **url)
if (scheme)
if (!worker) {
NULL));
return OK;
int ok = 0;
if (!ok) {
request_rec *r,
int access_status;
if (!*balancer &&
return DECLINED;
return DECLINED;
if (runtime) {
int i, total_factor = 0;
workers++;
int i, member_of = 0;
workers++;
if (member_of) {
return HTTP_SERVICE_UNAVAILABLE;
if (!*worker) {
if (!runtime) {
return HTTP_SERVICE_UNAVAILABLE;
if (route) {
return access_status;
request_rec *r,
return HTTP_INTERNAL_SERVER_ERROR;
return OK;
void *data;
if (!data) {
return OK;
int access_status;
const char *name;
return DECLINED;
return DECLINED;
if (r->args) {
return access_status;
return HTTP_BAD_REQUEST;
if (*balancer_nonce &&
++workers;
if (wsel) {
const char *val;
if (bsel)
++workers;
++balancer;
NULL);
++workers;
++balancer;
NULL);
NULL);
return OK;
balancer++;
s = s->next;
const char *val)
return err;
if (val) {
return NULL;
{NULL}