From 1f6fd365c39e9b324394fc940bd66ef09bc4f870 Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Wed, 7 Jan 2015 10:36:12 +0000 Subject: [PATCH] mod_proxy: Don't put non balancer-member workers in error state by default for connection or 500/503 errors, and honor status=+I for any error. PR 48388. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1650028 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 4 ++++ modules/proxy/mod_proxy.c | 6 ++++-- modules/proxy/mod_proxy_balancer.c | 4 +++- modules/proxy/proxy_util.c | 6 +++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 559013b98d..35f02abdaf 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mod_proxy: Don't put non balancer-member workers in error state by + default for connection or 500/503 errors, and honor status=+I for + any error. PR 48388. [Yann Ylavic] + *) mod_include: the 'env' function was incorrectly handled as 'getenv' if the leading 'e' was written in upper case in statements. [Christophe Jaillet] diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 26c37b6fec..06ec750387 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -1172,7 +1172,8 @@ static int proxy_handler(request_rec *r) * We can not failover to another worker. * Mark the worker as unusable if member of load balancer */ - if (balancer) { + if (balancer + && !(worker->s->status & PROXY_WORKER_IGNORE_ERRORS)) { worker->s->status |= PROXY_WORKER_IN_ERROR; worker->s->error_time = apr_time_now(); } @@ -1183,7 +1184,8 @@ static int proxy_handler(request_rec *r) * We can failover to another worker * Mark the worker as unusable if member of load balancer */ - if (balancer) { + if (balancer + && !(worker->s->status & PROXY_WORKER_IGNORE_ERRORS)) { worker->s->status |= PROXY_WORKER_IN_ERROR; worker->s->error_time = apr_time_now(); } diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index f33aa936d5..d2f9f5b5ac 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -633,7 +633,8 @@ static int proxy_balancer_post_request(proxy_worker *worker, return HTTP_INTERNAL_SERVER_ERROR; } - if (!apr_is_empty_array(balancer->errstatuses)) { + if (!apr_is_empty_array(balancer->errstatuses) + && !(worker->s->status & PROXY_WORKER_IGNORE_ERRORS)) { int i; for (i = 0; i < balancer->errstatuses->nelts; i++) { int val = ((int *)balancer->errstatuses->elts)[i]; @@ -652,6 +653,7 @@ static int proxy_balancer_post_request(proxy_worker *worker, } if (balancer->failontimeout + && !(worker->s->status & PROXY_WORKER_IGNORE_ERRORS) && (apr_table_get(r->notes, "proxy_timedout")) != NULL) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02460) "%s: Forcing worker (%s) into error state " diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index 624d1ad3bf..29635876ff 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -1767,6 +1767,9 @@ PROXY_DECLARE(char *) ap_proxy_define_worker(apr_pool_t *p, else { *wshared->uds_path = '\0'; } + if (!balancer) { + wshared->status |= PROXY_WORKER_IGNORE_ERRORS; + } (*worker)->hash = wshared->hash; (*worker)->context = NULL; @@ -1951,7 +1954,8 @@ static int ap_proxy_retry_worker(const char *proxy_function, proxy_worker *worke server_rec *s) { if (worker->s->status & PROXY_WORKER_IN_ERROR) { - if (apr_time_now() > worker->s->error_time + worker->s->retry) { + if ((worker->s->status & PROXY_WORKER_IGNORE_ERRORS) + || apr_time_now() > worker->s->error_time + worker->s->retry) { ++worker->s->retries; worker->s->status &= ~PROXY_WORKER_IN_ERROR; ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(00932) -- 2.40.0