mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
Change the order of mod_proxy and mod_proxy_balancer child_init().
Change the balancer workers area to the address of workers instead copying the workers. Arrange lbmethod accordingly. Move the creation of conf->forward worker to mod_proxy child_init(). git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@771940 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -27,7 +27,7 @@ static proxy_worker *find_best_bybusyness(proxy_balancer *balancer,
|
||||
{
|
||||
|
||||
int i;
|
||||
proxy_worker *worker;
|
||||
proxy_worker **worker;
|
||||
proxy_worker *mycandidate = NULL;
|
||||
int cur_lbset = 0;
|
||||
int max_lbset = 0;
|
||||
@@ -46,17 +46,17 @@ static proxy_worker *find_best_bybusyness(proxy_balancer *balancer,
|
||||
checking_standby = checked_standby = 0;
|
||||
while (!mycandidate && !checked_standby) {
|
||||
|
||||
worker = (proxy_worker *)balancer->workers->elts;
|
||||
worker = (proxy_worker **)balancer->workers->elts;
|
||||
for (i = 0; i < balancer->workers->nelts; i++, worker++) {
|
||||
if (!checking_standby) { /* first time through */
|
||||
if (worker->s->lbset > max_lbset)
|
||||
max_lbset = worker->s->lbset;
|
||||
if ((*worker)->s->lbset > max_lbset)
|
||||
max_lbset = (*worker)->s->lbset;
|
||||
}
|
||||
|
||||
if (worker->s->lbset != cur_lbset)
|
||||
if ((*worker)->s->lbset != cur_lbset)
|
||||
continue;
|
||||
|
||||
if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) )
|
||||
if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(*worker) : PROXY_WORKER_IS_STANDBY(*worker)) )
|
||||
continue;
|
||||
|
||||
/* If the worker is in error state run
|
||||
@@ -65,21 +65,21 @@ static proxy_worker *find_best_bybusyness(proxy_balancer *balancer,
|
||||
* The worker might still be unusable, but we try
|
||||
* anyway.
|
||||
*/
|
||||
if (!PROXY_WORKER_IS_USABLE(worker))
|
||||
ap_proxy_retry_worker("BALANCER", worker, r->server);
|
||||
if (!PROXY_WORKER_IS_USABLE(*worker))
|
||||
ap_proxy_retry_worker("BALANCER", *worker, r->server);
|
||||
|
||||
/* Take into calculation only the workers that are
|
||||
* not in error state or not disabled.
|
||||
*/
|
||||
if (PROXY_WORKER_IS_USABLE(worker)) {
|
||||
if (PROXY_WORKER_IS_USABLE(*worker)) {
|
||||
|
||||
worker->s->lbstatus += worker->s->lbfactor;
|
||||
total_factor += worker->s->lbfactor;
|
||||
(*worker)->s->lbstatus += (*worker)->s->lbfactor;
|
||||
total_factor += (*worker)->s->lbfactor;
|
||||
|
||||
if (!mycandidate
|
||||
|| worker->s->busy < mycandidate->s->busy
|
||||
|| (worker->s->busy == mycandidate->s->busy && worker->s->lbstatus > mycandidate->s->lbstatus))
|
||||
mycandidate = worker;
|
||||
|| (*worker)->s->busy < mycandidate->s->busy
|
||||
|| ((*worker)->s->busy == mycandidate->s->busy && (*worker)->s->lbstatus > mycandidate->s->lbstatus))
|
||||
mycandidate = *worker;
|
||||
|
||||
}
|
||||
|
||||
|
@@ -73,7 +73,7 @@ static proxy_worker *find_best_byrequests(proxy_balancer *balancer,
|
||||
{
|
||||
int i;
|
||||
int total_factor = 0;
|
||||
proxy_worker *worker;
|
||||
proxy_worker **worker;
|
||||
proxy_worker *mycandidate = NULL;
|
||||
int cur_lbset = 0;
|
||||
int max_lbset = 0;
|
||||
@@ -88,15 +88,15 @@ static proxy_worker *find_best_byrequests(proxy_balancer *balancer,
|
||||
do {
|
||||
checking_standby = checked_standby = 0;
|
||||
while (!mycandidate && !checked_standby) {
|
||||
worker = (proxy_worker *)balancer->workers->elts;
|
||||
worker = (proxy_worker **)balancer->workers->elts;
|
||||
for (i = 0; i < balancer->workers->nelts; i++, worker++) {
|
||||
if (!checking_standby) { /* first time through */
|
||||
if (worker->s->lbset > max_lbset)
|
||||
max_lbset = worker->s->lbset;
|
||||
if ((*worker)->s->lbset > max_lbset)
|
||||
max_lbset = (*worker)->s->lbset;
|
||||
}
|
||||
if (worker->s->lbset != cur_lbset)
|
||||
if ((*worker)->s->lbset != cur_lbset)
|
||||
continue;
|
||||
if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) )
|
||||
if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(*worker) : PROXY_WORKER_IS_STANDBY(*worker)) )
|
||||
continue;
|
||||
/* If the worker is in error state run
|
||||
* retry on that worker. It will be marked as
|
||||
@@ -104,16 +104,16 @@ static proxy_worker *find_best_byrequests(proxy_balancer *balancer,
|
||||
* The worker might still be unusable, but we try
|
||||
* anyway.
|
||||
*/
|
||||
if (!PROXY_WORKER_IS_USABLE(worker))
|
||||
ap_proxy_retry_worker("BALANCER", worker, r->server);
|
||||
if (!PROXY_WORKER_IS_USABLE(*worker))
|
||||
ap_proxy_retry_worker("BALANCER", *worker, r->server);
|
||||
/* Take into calculation only the workers that are
|
||||
* not in error state or not disabled.
|
||||
*/
|
||||
if (PROXY_WORKER_IS_USABLE(worker)) {
|
||||
worker->s->lbstatus += worker->s->lbfactor;
|
||||
total_factor += worker->s->lbfactor;
|
||||
if (!mycandidate || worker->s->lbstatus > mycandidate->s->lbstatus)
|
||||
mycandidate = worker;
|
||||
if (PROXY_WORKER_IS_USABLE(*worker)) {
|
||||
(*worker)->s->lbstatus += (*worker)->s->lbfactor;
|
||||
total_factor += (*worker)->s->lbfactor;
|
||||
if (!mycandidate || (*worker)->s->lbstatus > mycandidate->s->lbstatus)
|
||||
mycandidate = *worker;
|
||||
}
|
||||
}
|
||||
checked_standby = checking_standby++;
|
||||
|
@@ -45,7 +45,7 @@ static proxy_worker *find_best_bytraffic(proxy_balancer *balancer,
|
||||
int i;
|
||||
apr_off_t mytraffic = 0;
|
||||
apr_off_t curmin = 0;
|
||||
proxy_worker *worker;
|
||||
proxy_worker **worker;
|
||||
proxy_worker *mycandidate = NULL;
|
||||
int cur_lbset = 0;
|
||||
int max_lbset = 0;
|
||||
@@ -60,15 +60,15 @@ static proxy_worker *find_best_bytraffic(proxy_balancer *balancer,
|
||||
do {
|
||||
checking_standby = checked_standby = 0;
|
||||
while (!mycandidate && !checked_standby) {
|
||||
worker = (proxy_worker *)balancer->workers->elts;
|
||||
worker = (proxy_worker **)balancer->workers->elts;
|
||||
for (i = 0; i < balancer->workers->nelts; i++, worker++) {
|
||||
if (!checking_standby) { /* first time through */
|
||||
if (worker->s->lbset > max_lbset)
|
||||
max_lbset = worker->s->lbset;
|
||||
if ((*worker)->s->lbset > max_lbset)
|
||||
max_lbset = (*worker)->s->lbset;
|
||||
}
|
||||
if (worker->s->lbset != cur_lbset)
|
||||
if ((*worker)->s->lbset != cur_lbset)
|
||||
continue;
|
||||
if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) )
|
||||
if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(*worker) : PROXY_WORKER_IS_STANDBY(*worker)) )
|
||||
continue;
|
||||
/* If the worker is in error state run
|
||||
* retry on that worker. It will be marked as
|
||||
@@ -76,16 +76,16 @@ static proxy_worker *find_best_bytraffic(proxy_balancer *balancer,
|
||||
* The worker might still be unusable, but we try
|
||||
* anyway.
|
||||
*/
|
||||
if (!PROXY_WORKER_IS_USABLE(worker))
|
||||
ap_proxy_retry_worker("BALANCER", worker, r->server);
|
||||
if (!PROXY_WORKER_IS_USABLE(*worker))
|
||||
ap_proxy_retry_worker("BALANCER", *worker, r->server);
|
||||
/* Take into calculation only the workers that are
|
||||
* not in error state or not disabled.
|
||||
*/
|
||||
if (PROXY_WORKER_IS_USABLE(worker)) {
|
||||
mytraffic = (worker->s->transferred/worker->s->lbfactor) +
|
||||
(worker->s->read/worker->s->lbfactor);
|
||||
if (PROXY_WORKER_IS_USABLE(*worker)) {
|
||||
mytraffic = ((*worker)->s->transferred/(*worker)->s->lbfactor) +
|
||||
((*worker)->s->read/(*worker)->s->lbfactor);
|
||||
if (!mycandidate || mytraffic < curmin) {
|
||||
mycandidate = worker;
|
||||
mycandidate = *worker;
|
||||
curmin = mytraffic;
|
||||
}
|
||||
}
|
||||
|
@@ -223,7 +223,7 @@ static proxy_worker *find_best_hb(proxy_balancer *balancer,
|
||||
apr_status_t rv;
|
||||
int i;
|
||||
apr_uint32_t openslots = 0;
|
||||
proxy_worker *worker;
|
||||
proxy_worker **worker;
|
||||
hb_server_t *server;
|
||||
apr_array_header_t *up_servers;
|
||||
proxy_worker *mycandidate = NULL;
|
||||
@@ -251,19 +251,19 @@ static proxy_worker *find_best_hb(proxy_balancer *balancer,
|
||||
up_servers = apr_array_make(tpool, apr_hash_count(servers), sizeof(hb_server_t *));
|
||||
|
||||
for (i = 0; i < balancer->workers->nelts; i++) {
|
||||
worker = &APR_ARRAY_IDX(balancer->workers, i, proxy_worker);
|
||||
server = apr_hash_get(servers, worker->hostname, APR_HASH_KEY_STRING);
|
||||
worker = &APR_ARRAY_IDX(balancer->workers, i, proxy_worker *);
|
||||
server = apr_hash_get(servers, (*worker)->hostname, APR_HASH_KEY_STRING);
|
||||
|
||||
if (!server) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!PROXY_WORKER_IS_USABLE(worker)) {
|
||||
ap_proxy_retry_worker("BALANCER", worker, r->server);
|
||||
if (!PROXY_WORKER_IS_USABLE(*worker)) {
|
||||
ap_proxy_retry_worker("BALANCER", *worker, r->server);
|
||||
}
|
||||
|
||||
if (PROXY_WORKER_IS_USABLE(worker)) {
|
||||
server->worker = worker;
|
||||
if (PROXY_WORKER_IS_USABLE(*worker)) {
|
||||
server->worker = *worker;
|
||||
if (server->seen < LBM_HEARTBEAT_MAX_LASTSEEN) {
|
||||
openslots += server->ready;
|
||||
APR_ARRAY_PUSH(up_servers, hb_server_t *) = server;
|
||||
|
@@ -43,7 +43,7 @@ static proxy_worker *find_best_roundrobin(proxy_balancer *balancer,
|
||||
request_rec *r)
|
||||
{
|
||||
int i;
|
||||
proxy_worker *worker;
|
||||
proxy_worker **worker;
|
||||
proxy_worker *mycandidate = NULL;
|
||||
int checking_standby;
|
||||
int checked_standby;
|
||||
@@ -70,17 +70,17 @@ static proxy_worker *find_best_roundrobin(proxy_balancer *balancer,
|
||||
|
||||
checking_standby = checked_standby = 0;
|
||||
while (!mycandidate && !checked_standby) {
|
||||
worker = (proxy_worker *)balancer->workers->elts;
|
||||
worker = (proxy_worker **)balancer->workers->elts;
|
||||
|
||||
for (i = 0; i < balancer->workers->nelts; i++, worker++) {
|
||||
if (i < ctx->index)
|
||||
continue;
|
||||
if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) )
|
||||
if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(*worker) : PROXY_WORKER_IS_STANDBY(*worker)) )
|
||||
continue;
|
||||
if (!PROXY_WORKER_IS_USABLE(worker))
|
||||
ap_proxy_retry_worker("BALANCER", worker, r->server);
|
||||
if (PROXY_WORKER_IS_USABLE(worker)) {
|
||||
mycandidate = worker;
|
||||
if (!PROXY_WORKER_IS_USABLE(*worker))
|
||||
ap_proxy_retry_worker("BALANCER", *worker, r->server);
|
||||
if (PROXY_WORKER_IS_USABLE(*worker)) {
|
||||
mycandidate = *worker;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -1591,13 +1591,6 @@ static const char *
|
||||
|
||||
psf->req = flag;
|
||||
psf->req_set = 1;
|
||||
|
||||
if (flag && !psf->forward) {
|
||||
psf->forward = ap_proxy_create_worker(parms->pool);
|
||||
psf->forward->name = "proxy:forward";
|
||||
psf->forward->hostname = "*";
|
||||
psf->forward->scheme = "*";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1821,7 +1814,7 @@ static const char *add_member(cmd_parms *cmd, void *dummy, const char *arg)
|
||||
return apr_pstrcat(cmd->temp_pool, "BalancerMember ", err, NULL);
|
||||
}
|
||||
/* Add the worker to the load balancer */
|
||||
ap_proxy_add_worker_to_balancer(cmd->pool, balancer, worker);
|
||||
ap_proxy_add_worker_to_balancer(cmd->pool, balancer, &worker);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -2203,7 +2196,7 @@ static int proxy_status_hook(request_rec *r, int flags)
|
||||
proxy_server_conf *conf = (proxy_server_conf *)
|
||||
ap_get_module_config(sconf, &proxy_module);
|
||||
proxy_balancer *balancer = NULL;
|
||||
proxy_worker *worker = NULL;
|
||||
proxy_worker **worker = NULL;
|
||||
|
||||
if (flags & AP_STATUS_SHORT || conf->balancers->nelts == 0 ||
|
||||
conf->proxy_status == status_off)
|
||||
@@ -2239,27 +2232,27 @@ static int proxy_status_hook(request_rec *r, int flags)
|
||||
"<th>F</th><th>Set</th><th>Acc</th><th>Wr</th><th>Rd</th>"
|
||||
"</tr>\n", r);
|
||||
|
||||
worker = (proxy_worker *)balancer->workers->elts;
|
||||
worker = (proxy_worker **)balancer->workers->elts;
|
||||
for (n = 0; n < balancer->workers->nelts; n++) {
|
||||
char fbuf[50];
|
||||
ap_rvputs(r, "<tr>\n<td>", worker->scheme, "</td>", NULL);
|
||||
ap_rvputs(r, "<td>", worker->hostname, "</td><td>", NULL);
|
||||
if (worker->s->status & PROXY_WORKER_DISABLED)
|
||||
ap_rvputs(r, "<tr>\n<td>", (*worker)->scheme, "</td>", NULL);
|
||||
ap_rvputs(r, "<td>", (*worker)->hostname, "</td><td>", NULL);
|
||||
if ((*worker)->s->status & PROXY_WORKER_DISABLED)
|
||||
ap_rputs("Dis", r);
|
||||
else if (worker->s->status & PROXY_WORKER_IN_ERROR)
|
||||
else if ((*worker)->s->status & PROXY_WORKER_IN_ERROR)
|
||||
ap_rputs("Err", r);
|
||||
else if (worker->s->status & PROXY_WORKER_INITIALIZED)
|
||||
else if ((*worker)->s->status & PROXY_WORKER_INITIALIZED)
|
||||
ap_rputs("Ok", r);
|
||||
else
|
||||
ap_rputs("-", r);
|
||||
ap_rvputs(r, "</td><td>", worker->s->route, NULL);
|
||||
ap_rvputs(r, "</td><td>", worker->s->redirect, NULL);
|
||||
ap_rprintf(r, "</td><td>%d</td>", worker->s->lbfactor);
|
||||
ap_rprintf(r, "<td>%d</td>", worker->s->lbset);
|
||||
ap_rprintf(r, "<td>%" APR_SIZE_T_FMT "</td><td>", worker->s->elected);
|
||||
ap_rputs(apr_strfsize(worker->s->transferred, fbuf), r);
|
||||
ap_rvputs(r, "</td><td>", (*worker)->s->route, NULL);
|
||||
ap_rvputs(r, "</td><td>", (*worker)->s->redirect, NULL);
|
||||
ap_rprintf(r, "</td><td>%d</td>", (*worker)->s->lbfactor);
|
||||
ap_rprintf(r, "<td>%d</td>", (*worker)->s->lbset);
|
||||
ap_rprintf(r, "<td>%" APR_SIZE_T_FMT "</td><td>", (*worker)->s->elected);
|
||||
ap_rputs(apr_strfsize((*worker)->s->transferred, fbuf), r);
|
||||
ap_rputs("</td><td>", r);
|
||||
ap_rputs(apr_strfsize(worker->s->read, fbuf), r);
|
||||
ap_rputs(apr_strfsize((*worker)->s->read, fbuf), r);
|
||||
ap_rputs("</td>\n", r);
|
||||
|
||||
/* TODO: Add the rest of dynamic worker data */
|
||||
@@ -2305,8 +2298,12 @@ static void child_init(apr_pool_t *p, server_rec *s)
|
||||
ap_proxy_initialize_worker(worker, s);
|
||||
worker++;
|
||||
}
|
||||
/* Initialize forward worker if defined */
|
||||
if (conf->forward) {
|
||||
/* Create and initialize forward worker if defined */
|
||||
if (conf->req_set && conf->req) {
|
||||
conf->forward = ap_proxy_create_worker(p);
|
||||
conf->forward->name = "proxy:forward";
|
||||
conf->forward->hostname = "*";
|
||||
conf->forward->scheme = "*";
|
||||
ap_proxy_initialize_worker_share(conf, conf->forward, s);
|
||||
ap_proxy_initialize_worker(conf->forward, s);
|
||||
/* Do not disable worker in case of errors */
|
||||
@@ -2354,7 +2351,7 @@ static void register_hooks(apr_pool_t *p)
|
||||
* make sure that we are called after the mpm
|
||||
* initializes.
|
||||
*/
|
||||
static const char *const aszPred[] = { "mpm_winnt.c", NULL};
|
||||
static const char *const aszPred[] = { "mpm_winnt.c", "mod_proxy_balancer.c", NULL};
|
||||
|
||||
APR_REGISTER_OPTIONAL_FN(ap_proxy_lb_workers);
|
||||
APR_REGISTER_OPTIONAL_FN(ap_proxy_lb_worker_size);
|
||||
|
@@ -601,12 +601,12 @@ PROXY_DECLARE(const char *) ap_proxy_add_balancer(proxy_balancer **balancer,
|
||||
* Add the worker to the balancer
|
||||
* @param pool memory pool for adding worker
|
||||
* @param balancer balancer to add to
|
||||
* @param balancer worker to add
|
||||
* @param address of balancer worker to add
|
||||
* @note Single worker can be added to multiple balancers.
|
||||
*/
|
||||
PROXY_DECLARE(void) ap_proxy_add_worker_to_balancer(apr_pool_t *pool,
|
||||
proxy_balancer *balancer,
|
||||
proxy_worker *worker);
|
||||
proxy_worker **worker);
|
||||
/**
|
||||
* Get the most suitable worker and(or) balancer for the request
|
||||
* @param worker worker used for processing request
|
||||
|
@@ -82,20 +82,20 @@ static int init_balancer_members(proxy_server_conf *conf, server_rec *s,
|
||||
proxy_balancer *balancer)
|
||||
{
|
||||
int i;
|
||||
proxy_worker *workers;
|
||||
proxy_worker **workers;
|
||||
|
||||
workers = (proxy_worker *)balancer->workers->elts;
|
||||
workers = (proxy_worker **)balancer->workers->elts;
|
||||
|
||||
for (i = 0; i < balancer->workers->nelts; i++) {
|
||||
int worker_is_initialized;
|
||||
worker_is_initialized = PROXY_WORKER_IS_INITIALIZED(workers);
|
||||
worker_is_initialized = PROXY_WORKER_IS_INITIALIZED(*workers);
|
||||
if (!worker_is_initialized) {
|
||||
proxy_worker_stat *slot;
|
||||
/*
|
||||
* If the worker is not initialized check whether its scoreboard
|
||||
* slot is already initialized.
|
||||
*/
|
||||
slot = (proxy_worker_stat *) ap_get_scoreboard_lb(workers->id);
|
||||
slot = (proxy_worker_stat *) ap_get_scoreboard_lb((*workers)->id);
|
||||
if (slot) {
|
||||
worker_is_initialized = slot->status & PROXY_WORKER_INITIALIZED;
|
||||
}
|
||||
@@ -103,13 +103,13 @@ static int init_balancer_members(proxy_server_conf *conf, server_rec *s,
|
||||
worker_is_initialized = 0;
|
||||
}
|
||||
}
|
||||
ap_proxy_initialize_worker_share(conf, workers, s);
|
||||
ap_proxy_initialize_worker(workers, s);
|
||||
ap_proxy_initialize_worker_share(conf, *workers, s);
|
||||
ap_proxy_initialize_worker(*workers, s);
|
||||
if (!worker_is_initialized) {
|
||||
/* Set to the original configuration */
|
||||
workers->s->lbstatus = workers->s->lbfactor =
|
||||
(workers->lbfactor ? workers->lbfactor : 1);
|
||||
workers->s->lbset = workers->lbset;
|
||||
(*workers)->s->lbstatus = (*workers)->s->lbfactor =
|
||||
((*workers)->lbfactor ? (*workers)->lbfactor : 1);
|
||||
(*workers)->s->lbset = (*workers)->lbset;
|
||||
}
|
||||
++workers;
|
||||
}
|
||||
@@ -401,18 +401,18 @@ static void force_recovery(proxy_balancer *balancer, server_rec *s)
|
||||
{
|
||||
int i;
|
||||
int ok = 0;
|
||||
proxy_worker *worker;
|
||||
proxy_worker **worker;
|
||||
|
||||
worker = (proxy_worker *)balancer->workers->elts;
|
||||
worker = (proxy_worker **)balancer->workers->elts;
|
||||
for (i = 0; i < balancer->workers->nelts; i++, worker++) {
|
||||
if (!(worker->s->status & PROXY_WORKER_IN_ERROR)) {
|
||||
if (!((*worker)->s->status & PROXY_WORKER_IN_ERROR)) {
|
||||
ok = 1;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
/* Try if we can recover */
|
||||
ap_proxy_retry_worker("BALANCER", worker, s);
|
||||
if (!(worker->s->status & PROXY_WORKER_IN_ERROR)) {
|
||||
ap_proxy_retry_worker("BALANCER", *worker, s);
|
||||
if (!((*worker)->s->status & PROXY_WORKER_IN_ERROR)) {
|
||||
ok = 1;
|
||||
break;
|
||||
}
|
||||
@@ -421,13 +421,13 @@ static void force_recovery(proxy_balancer *balancer, server_rec *s)
|
||||
if (!ok) {
|
||||
/* If all workers are in error state force the recovery.
|
||||
*/
|
||||
worker = (proxy_worker *)balancer->workers->elts;
|
||||
worker = (proxy_worker **)balancer->workers->elts;
|
||||
for (i = 0; i < balancer->workers->nelts; i++, worker++) {
|
||||
++worker->s->retries;
|
||||
worker->s->status &= ~PROXY_WORKER_IN_ERROR;
|
||||
++(*worker)->s->retries;
|
||||
(*worker)->s->status &= ~PROXY_WORKER_IN_ERROR;
|
||||
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
|
||||
"proxy: BALANCER: (%s). Forcing recovery for worker (%s)",
|
||||
balancer->name, worker->hostname);
|
||||
balancer->name, (*worker)->hostname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -955,7 +955,7 @@ static void ap_proxy_balancer_register_hook(apr_pool_t *p)
|
||||
* make sure that we are called after the mpm
|
||||
* initializes and after the mod_proxy
|
||||
*/
|
||||
static const char *const aszPred[] = { "mpm_winnt.c", "mod_proxy.c", NULL};
|
||||
static const char *const aszPred[] = { "mpm_winnt.c", NULL};
|
||||
/* manager handler */
|
||||
ap_hook_post_config(balancer_init, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
ap_hook_handler(balancer_handler, NULL, NULL, APR_HOOK_FIRST);
|
||||
|
@@ -1081,7 +1081,7 @@ PROXY_DECLARE(const char *) ap_proxy_location_reverse_map(request_rec *r,
|
||||
if ((strncasecmp(real, "balancer://", 11) == 0) &&
|
||||
(balancer = ap_proxy_get_balancer(r->pool, sconf, real))) {
|
||||
int n, l3 = 0;
|
||||
proxy_worker *worker = (proxy_worker *)balancer->workers->elts;
|
||||
proxy_worker **worker = (proxy_worker **)balancer->workers->elts;
|
||||
const char *urlpart = ap_strchr_c(real + 11, '/');
|
||||
if (urlpart) {
|
||||
if (!urlpart[1])
|
||||
@@ -1095,20 +1095,20 @@ PROXY_DECLARE(const char *) ap_proxy_location_reverse_map(request_rec *r,
|
||||
* translate url http://example.com/foo/bar/that to /bash/that
|
||||
*/
|
||||
for (n = 0; n < balancer->workers->nelts; n++) {
|
||||
l2 = strlen(worker->name);
|
||||
l2 = strlen((*worker)->name);
|
||||
if (urlpart) {
|
||||
/* urlpart (l3) assuredly starts with its own '/' */
|
||||
if (worker->name[l2 - 1] == '/')
|
||||
if ((*worker)->name[l2 - 1] == '/')
|
||||
--l2;
|
||||
if (l1 >= l2 + l3
|
||||
&& strncasecmp(worker->name, url, l2) == 0
|
||||
&& strncasecmp((*worker)->name, url, l2) == 0
|
||||
&& strncmp(urlpart, url + l2, l3) == 0) {
|
||||
u = apr_pstrcat(r->pool, ent[i].fake, &url[l2 + l3],
|
||||
NULL);
|
||||
return ap_construct_url(r->pool, u, r);
|
||||
}
|
||||
}
|
||||
else if (l1 >= l2 && strncasecmp(worker->name, url, l2) == 0) {
|
||||
else if (l1 >= l2 && strncasecmp((*worker)->name, url, l2) == 0) {
|
||||
u = apr_pstrcat(r->pool, ent[i].fake, &url[l2], NULL);
|
||||
return ap_construct_url(r->pool, u, r);
|
||||
}
|
||||
@@ -1303,7 +1303,7 @@ PROXY_DECLARE(const char *) ap_proxy_add_balancer(proxy_balancer **balancer,
|
||||
|
||||
(*balancer)->name = uri;
|
||||
(*balancer)->lbmethod = lbmethod;
|
||||
(*balancer)->workers = apr_array_make(p, 5, sizeof(proxy_worker));
|
||||
(*balancer)->workers = apr_array_make(p, 5, sizeof(proxy_worker *));
|
||||
/* XXX Is this a right place to create mutex */
|
||||
#if APR_HAS_THREADS
|
||||
if (apr_thread_mutex_create(&((*balancer)->mutex),
|
||||
@@ -1471,13 +1471,13 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_create_worker(apr_pool_t *p)
|
||||
|
||||
PROXY_DECLARE(void)
|
||||
ap_proxy_add_worker_to_balancer(apr_pool_t *pool, proxy_balancer *balancer,
|
||||
proxy_worker *worker)
|
||||
proxy_worker **worker)
|
||||
{
|
||||
proxy_worker *runtime;
|
||||
proxy_worker **runtime;
|
||||
|
||||
runtime = apr_array_push(balancer->workers);
|
||||
memcpy(runtime, worker, sizeof(proxy_worker));
|
||||
runtime->id = proxy_lb_workers;
|
||||
memcpy(runtime, worker, sizeof(proxy_worker *));
|
||||
(*runtime)->id = proxy_lb_workers;
|
||||
/* Increase the total runtime count */
|
||||
proxy_lb_workers++;
|
||||
|
||||
|
Reference in New Issue
Block a user