mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
Fix crash in balancer-manager.
This was due to an incomplete refactoring in r771940 (switching balancer->workers to an array of pointers). It's likely that other balancer functionality was broken too. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@891230 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
Changes with Apache 2.3.5
|
Changes with Apache 2.3.5
|
||||||
|
|
||||||
|
*) mod_proxy_balancer: Fix crash in balancer-manager. [Rainer Jung]
|
||||||
|
|
||||||
*) mod_headers: Ensure that changes to the main request remain valid when
|
*) mod_headers: Ensure that changes to the main request remain valid when
|
||||||
the subrequest is destroyed. PR 48359 [Nick Kew, Ruediger Pluem]
|
the subrequest is destroyed. PR 48359 [Nick Kew, Ruediger Pluem]
|
||||||
|
|
||||||
|
@@ -197,12 +197,14 @@ static proxy_worker *find_route_worker(proxy_balancer *balancer,
|
|||||||
int checking_standby;
|
int checking_standby;
|
||||||
int checked_standby;
|
int checked_standby;
|
||||||
|
|
||||||
|
proxy_worker **workers;
|
||||||
proxy_worker *worker;
|
proxy_worker *worker;
|
||||||
|
|
||||||
checking_standby = checked_standby = 0;
|
checking_standby = checked_standby = 0;
|
||||||
while (!checked_standby) {
|
while (!checked_standby) {
|
||||||
worker = (proxy_worker *)balancer->workers->elts;
|
workers = (proxy_worker **)balancer->workers->elts;
|
||||||
for (i = 0; i < balancer->workers->nelts; i++, worker++) {
|
for (i = 0; i < balancer->workers->nelts; i++, workers++) {
|
||||||
|
worker = *workers;
|
||||||
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;
|
continue;
|
||||||
if (*(worker->s->route) && strcmp(worker->s->route, route) == 0) {
|
if (*(worker->s->route) && strcmp(worker->s->route, route) == 0) {
|
||||||
@@ -470,13 +472,13 @@ static int proxy_balancer_pre_request(proxy_worker **worker,
|
|||||||
runtime = find_session_route(*balancer, r, &route, &sticky, url);
|
runtime = find_session_route(*balancer, r, &route, &sticky, url);
|
||||||
if (runtime) {
|
if (runtime) {
|
||||||
int i, total_factor = 0;
|
int i, total_factor = 0;
|
||||||
proxy_worker *workers;
|
proxy_worker **workers;
|
||||||
/* We have a sticky load balancer
|
/* We have a sticky load balancer
|
||||||
* Update the workers status
|
* Update the workers status
|
||||||
* so that even session routes get
|
* so that even session routes get
|
||||||
* into account.
|
* into account.
|
||||||
*/
|
*/
|
||||||
workers = (proxy_worker *)(*balancer)->workers->elts;
|
workers = (proxy_worker **)(*balancer)->workers->elts;
|
||||||
for (i = 0; i < (*balancer)->workers->nelts; i++) {
|
for (i = 0; i < (*balancer)->workers->nelts; i++) {
|
||||||
/* Take into calculation only the workers that are
|
/* Take into calculation only the workers that are
|
||||||
* not in error state or not disabled.
|
* not in error state or not disabled.
|
||||||
@@ -484,9 +486,9 @@ static int proxy_balancer_pre_request(proxy_worker **worker,
|
|||||||
* TODO: Abstract the below, since this is dependent
|
* TODO: Abstract the below, since this is dependent
|
||||||
* on the LB implementation
|
* on the LB implementation
|
||||||
*/
|
*/
|
||||||
if (PROXY_WORKER_IS_USABLE(workers)) {
|
if (PROXY_WORKER_IS_USABLE(*workers)) {
|
||||||
workers->s->lbstatus += workers->s->lbfactor;
|
(*workers)->s->lbstatus += (*workers)->s->lbfactor;
|
||||||
total_factor += workers->s->lbfactor;
|
total_factor += (*workers)->s->lbfactor;
|
||||||
}
|
}
|
||||||
workers++;
|
workers++;
|
||||||
}
|
}
|
||||||
@@ -497,15 +499,15 @@ static int proxy_balancer_pre_request(proxy_worker **worker,
|
|||||||
}
|
}
|
||||||
else if (route && (*balancer)->sticky_force) {
|
else if (route && (*balancer)->sticky_force) {
|
||||||
int i, member_of = 0;
|
int i, member_of = 0;
|
||||||
proxy_worker *workers;
|
proxy_worker **workers;
|
||||||
/*
|
/*
|
||||||
* We have a route provided that doesn't match the
|
* We have a route provided that doesn't match the
|
||||||
* balancer name. See if the provider route is the
|
* balancer name. See if the provider route is the
|
||||||
* member of the same balancer in which case return 503
|
* member of the same balancer in which case return 503
|
||||||
*/
|
*/
|
||||||
workers = (proxy_worker *)(*balancer)->workers->elts;
|
workers = (proxy_worker **)(*balancer)->workers->elts;
|
||||||
for (i = 0; i < (*balancer)->workers->nelts; i++) {
|
for (i = 0; i < (*balancer)->workers->nelts; i++) {
|
||||||
if (*(workers->s->route) && strcmp(workers->s->route, route) == 0) {
|
if (*((*workers)->s->route) && strcmp((*workers)->s->route, route) == 0) {
|
||||||
member_of = 1;
|
member_of = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -630,21 +632,21 @@ static int proxy_balancer_post_request(proxy_worker *worker,
|
|||||||
static void recalc_factors(proxy_balancer *balancer)
|
static void recalc_factors(proxy_balancer *balancer)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
proxy_worker *workers;
|
proxy_worker **workers;
|
||||||
|
|
||||||
|
|
||||||
/* Recalculate lbfactors */
|
/* Recalculate lbfactors */
|
||||||
workers = (proxy_worker *)balancer->workers->elts;
|
workers = (proxy_worker **)balancer->workers->elts;
|
||||||
/* Special case if there is only one worker it's
|
/* Special case if there is only one worker it's
|
||||||
* load factor will always be 1
|
* load factor will always be 1
|
||||||
*/
|
*/
|
||||||
if (balancer->workers->nelts == 1) {
|
if (balancer->workers->nelts == 1) {
|
||||||
workers->s->lbstatus = workers->s->lbfactor = 1;
|
(*workers)->s->lbstatus = (*workers)->s->lbfactor = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (i = 0; i < balancer->workers->nelts; i++) {
|
for (i = 0; i < balancer->workers->nelts; i++) {
|
||||||
/* Update the status entries */
|
/* Update the status entries */
|
||||||
workers[i].s->lbstatus = workers[i].s->lbfactor;
|
workers[i]->s->lbstatus = workers[i]->s->lbfactor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -682,6 +684,7 @@ static int balancer_handler(request_rec *r)
|
|||||||
ap_get_module_config(sconf, &proxy_module);
|
ap_get_module_config(sconf, &proxy_module);
|
||||||
proxy_balancer *balancer, *bsel = NULL;
|
proxy_balancer *balancer, *bsel = NULL;
|
||||||
proxy_worker *worker, *wsel = NULL;
|
proxy_worker *worker, *wsel = NULL;
|
||||||
|
proxy_worker **workers = NULL;
|
||||||
apr_table_t *params = apr_table_make(r->pool, 10);
|
apr_table_t *params = apr_table_make(r->pool, 10);
|
||||||
int access_status;
|
int access_status;
|
||||||
int i, n;
|
int i, n;
|
||||||
@@ -731,13 +734,14 @@ static int balancer_handler(request_rec *r)
|
|||||||
|
|
||||||
ws = ap_proxy_get_worker(r->pool, conf, name);
|
ws = ap_proxy_get_worker(r->pool, conf, name);
|
||||||
if (bsel && ws) {
|
if (bsel && ws) {
|
||||||
worker = (proxy_worker *)bsel->workers->elts;
|
workers = (proxy_worker **)bsel->workers->elts;
|
||||||
for (n = 0; n < bsel->workers->nelts; n++) {
|
for (n = 0; n < bsel->workers->nelts; n++) {
|
||||||
|
worker = *workers;
|
||||||
if (strcasecmp(worker->name, ws->name) == 0) {
|
if (strcasecmp(worker->name, ws->name) == 0) {
|
||||||
wsel = worker;
|
wsel = worker;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++worker;
|
++workers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -792,8 +796,9 @@ static int balancer_handler(request_rec *r)
|
|||||||
ap_rputs(" <httpd:balancer>\n", r);
|
ap_rputs(" <httpd:balancer>\n", r);
|
||||||
ap_rvputs(r, " <httpd:name>", balancer->name, "</httpd:name>\n", NULL);
|
ap_rvputs(r, " <httpd:name>", balancer->name, "</httpd:name>\n", NULL);
|
||||||
ap_rputs(" <httpd:workers>\n", r);
|
ap_rputs(" <httpd:workers>\n", r);
|
||||||
worker = (proxy_worker *)balancer->workers->elts;
|
workers = (proxy_worker **)balancer->workers->elts;
|
||||||
for (n = 0; n < balancer->workers->nelts; n++) {
|
for (n = 0; n < balancer->workers->nelts; n++) {
|
||||||
|
worker = *workers;
|
||||||
ap_rputs(" <httpd:worker>\n", r);
|
ap_rputs(" <httpd:worker>\n", r);
|
||||||
ap_rvputs(r, " <httpd:scheme>", worker->scheme,
|
ap_rvputs(r, " <httpd:scheme>", worker->scheme,
|
||||||
"</httpd:scheme>\n", NULL);
|
"</httpd:scheme>\n", NULL);
|
||||||
@@ -802,7 +807,7 @@ static int balancer_handler(request_rec *r)
|
|||||||
ap_rprintf(r, " <httpd:loadfactor>%d</httpd:loadfactor>\n",
|
ap_rprintf(r, " <httpd:loadfactor>%d</httpd:loadfactor>\n",
|
||||||
worker->s->lbfactor);
|
worker->s->lbfactor);
|
||||||
ap_rputs(" </httpd:worker>\n", r);
|
ap_rputs(" </httpd:worker>\n", r);
|
||||||
++worker;
|
++workers;
|
||||||
}
|
}
|
||||||
ap_rputs(" </httpd:workers>\n", r);
|
ap_rputs(" </httpd:workers>\n", r);
|
||||||
ap_rputs(" </httpd:balancer>\n", r);
|
ap_rputs(" </httpd:balancer>\n", r);
|
||||||
@@ -854,9 +859,10 @@ static int balancer_handler(request_rec *r)
|
|||||||
"<th>Elected</th><th>To</th><th>From</th>"
|
"<th>Elected</th><th>To</th><th>From</th>"
|
||||||
"</tr>\n", r);
|
"</tr>\n", r);
|
||||||
|
|
||||||
worker = (proxy_worker *)balancer->workers->elts;
|
workers = (proxy_worker **)balancer->workers->elts;
|
||||||
for (n = 0; n < balancer->workers->nelts; n++) {
|
for (n = 0; n < balancer->workers->nelts; n++) {
|
||||||
char fbuf[50];
|
char fbuf[50];
|
||||||
|
worker = *workers;
|
||||||
ap_rvputs(r, "<tr>\n<td><a href=\"", r->uri, "?b=",
|
ap_rvputs(r, "<tr>\n<td><a href=\"", r->uri, "?b=",
|
||||||
balancer->name + sizeof("balancer://") - 1, "&w=",
|
balancer->name + sizeof("balancer://") - 1, "&w=",
|
||||||
ap_escape_uri(r->pool, worker->name),
|
ap_escape_uri(r->pool, worker->name),
|
||||||
@@ -888,7 +894,7 @@ static int balancer_handler(request_rec *r)
|
|||||||
ap_rputs(apr_strfsize(worker->s->read, fbuf), r);
|
ap_rputs(apr_strfsize(worker->s->read, fbuf), r);
|
||||||
ap_rputs("</td></tr>\n", r);
|
ap_rputs("</td></tr>\n", r);
|
||||||
|
|
||||||
++worker;
|
++workers;
|
||||||
}
|
}
|
||||||
ap_rputs("</table>\n", r);
|
ap_rputs("</table>\n", r);
|
||||||
++balancer;
|
++balancer;
|
||||||
|
Reference in New Issue
Block a user