]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_proxy_balancer: Restore balancing after a failed worker has
authorJeff Trawick <trawick@apache.org>
Fri, 27 Jul 2012 11:50:25 +0000 (11:50 +0000)
committerJeff Trawick <trawick@apache.org>
Fri, 27 Jul 2012 11:50:25 +0000 (11:50 +0000)
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

CHANGES
modules/proxy/mod_proxy_balancer.c

diff --git a/CHANGES b/CHANGES
index 87345203bdf789ec7981146b016d6fcd893fd8d5..ff79d4c51d8a9f84bebd297d58a1d7111a9ff013 100644 (file)
--- 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]
 
index e3db4883f1f70bf4d831e4909d4708a8df9f63fb..26bb1a8856fdb2bc93236d3f72b398b92604e93a 100644 (file)
@@ -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)