From: Mladen Turk Date: Tue, 17 Jul 2007 14:31:05 +0000 (+0000) Subject: Return 503 only if the route matches some of the balancer members and nofailover... X-Git-Tag: 2.3.0~1715 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7306af0a70b2a6f80637a9041e0feb5a183843cb;p=apache Return 503 only if the route matches some of the balancer members and nofailover=On is specified. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@556931 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index 10f2eec0ef..1a1d776334 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -470,15 +470,32 @@ static int proxy_balancer_pre_request(proxy_worker **worker, *worker = runtime; } else if (route && (*balancer)->sticky_force) { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, - "proxy: BALANCER: (%s). All workers are in error state for route (%s)", - (*balancer)->name, route); - if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server, - "proxy: BALANCER: (%s). Unlock failed for pre_request", - (*balancer)->name); + int i, member_of = 0; + proxy_worker *workers; + /* + * We have a route provided that doesn't match the + * balancer name. See if the provider route is the + * member of the same balancer in which case return 503 + */ + workers = (proxy_worker *)(*balancer)->workers->elts; + for (i = 0; i < (*balancer)->workers->nelts; i++) { + if (*(workers->s->route) && strcmp(workers->s->route, route) == 0) { + member_of = 1; + break; + } + workers++; + } + if (member_of) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, + "proxy: BALANCER: (%s). All workers are in error state for route (%s)", + (*balancer)->name, route); + if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server, + "proxy: BALANCER: (%s). Unlock failed for pre_request", + (*balancer)->name); + } + return HTTP_SERVICE_UNAVAILABLE; } - return HTTP_SERVICE_UNAVAILABLE; } if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) {