From: Jeff Trawick Date: Fri, 27 Jul 2012 11:50:25 +0000 (+0000) Subject: mod_proxy_balancer: Restore balancing after a failed worker has X-Git-Tag: 2.5.0-alpha~6579 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94b3a2b5522b395955a251fc1606c36c57daae98;p=thirdparty%2Fapache%2Fhttpd.git mod_proxy_balancer: Restore balancing after a failed worker has recovered when using lbmethod_bybusyness. PR: 48735 Markus Stoll and Adam C both submitted patches against 2.2.x to bug 48735. Compared with those two, this solution 1. resets the busy field in the error-ed worker at the end of the request instead of at recovery time 2. leaves the lbstatus field alone 3. covers all possible scenarios where the busy field in the error-ed worker needs to be adjusted, since a cleanup to perform the decrement is registered at the point of the increment git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1366344 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 87345203bdf..ff79d4c51d8 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mod_proxy_balancer: Restore balancing after a failed worker has + recovered when using lbmethod_bybusyness. PR 48735. [Jeff Trawick] + *) mod_proxy: Fix memory leak or possible corruption in ProxyBlock implementation. [Ruediger Pluem, Joe Orton] diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index e3db4883f1f..26bb1a8856f 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -437,6 +437,17 @@ static void force_recovery(proxy_balancer *balancer, server_rec *s) } } +static apr_status_t decrement_busy_count(void *worker_) +{ + proxy_worker *worker = worker_; + + if (worker->s->busy) { + worker->s->busy--; + } + + return APR_SUCCESS; +} + static int proxy_balancer_pre_request(proxy_worker **worker, proxy_balancer **balancer, request_rec *r, @@ -570,6 +581,8 @@ static int proxy_balancer_pre_request(proxy_worker **worker, } (*worker)->s->busy++; + apr_pool_cleanup_register(r->pool, *worker, decrement_busy_count, + apr_pool_cleanup_null); /* Add balancer/worker info to env. */ apr_table_setn(r->subprocess_env, @@ -642,11 +655,7 @@ static int proxy_balancer_post_request(proxy_worker *worker, ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01176) "proxy_balancer_post_request for (%s)", balancer->s->name); - if (worker && worker->s->busy) - worker->s->busy--; - return OK; - } static void recalc_factors(proxy_balancer *balancer)