]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r572937, r574485, r574486 from trunk:
authorJim Jagielski <jim@apache.org>
Fri, 14 Sep 2007 14:47:54 +0000 (14:47 +0000)
committerJim Jagielski <jim@apache.org>
Fri, 14 Sep 2007 14:47:54 +0000 (14:47 +0000)
Be proactively safe. A cheap check, but helps prevents badness :)

* Do not reset lbstatus, lbfactor and lbset if the shared proxy_worker_stat
  structure for a worker is already initialized by the same or another
  process.

* This check is now part of the PROXY_WORKER_IS_INITIALIZED macro.

Reviewed by: jim

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@575708 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_balancer.c
modules/proxy/proxy_util.c

index e78795256118c2e9c284468ac0e26bd083195aa0..8e2c5066c2273cb26470898c71ecac1e022e0c81 100644 (file)
@@ -254,14 +254,16 @@ struct proxy_conn_pool {
 #define PROXY_WORKER_NOT_USABLE_BITMAP ( PROXY_WORKER_IN_SHUTDOWN | \
 PROXY_WORKER_DISABLED | PROXY_WORKER_STOPPED | PROXY_WORKER_IN_ERROR )
 
-#define PROXY_WORKER_IS_INITIALIZED(f)   ( (f)->s->status & \
-  PROXY_WORKER_INITIALIZED )
+/* NOTE: these check the shared status */
+#define PROXY_WORKER_IS_INITIALIZED(f)   ( (f)->s && \
+  ( (f)->s->status &  PROXY_WORKER_INITIALIZED ) )
 
-#define PROXY_WORKER_IS_STANDBY(f)   ( (f)->s->status & \
-  PROXY_WORKER_HOT_STANDBY )
+#define PROXY_WORKER_IS_STANDBY(f)   ( (f)->s && \
+  ( (f)->s->status &  PROXY_WORKER_HOT_STANDBY ) )
 
-#define PROXY_WORKER_IS_USABLE(f)   ( !((f)->s->status & \
-  (PROXY_WORKER_NOT_USABLE_BITMAP)) && PROXY_WORKER_IS_INITIALIZED(f) )
+#define PROXY_WORKER_IS_USABLE(f)   ( (f)->s && \
+  ( !( (f)->s->status & PROXY_WORKER_NOT_USABLE_BITMAP) ) && \
+  PROXY_WORKER_IS_INITIALIZED(f) )
 
 /* default worker retry timeout in seconds */
 #define PROXY_WORKER_DEFAULT_RETRY  60
index e2f22235cf6f9384a6b4e12657bf898e499270ca..966f259e23ce4ca19125f189f8c9494c273d2a8a 100644 (file)
@@ -19,6 +19,7 @@
 #define CORE_PRIVATE
 
 #include "mod_proxy.h"
+#include "scoreboard.h"
 #include "ap_mpm.h"
 #include "apr_version.h"
 #include "apr_hooks.h"
@@ -79,22 +80,37 @@ static int init_balancer_members(proxy_server_conf *conf, server_rec *s,
 {
     int i;
     proxy_worker *workers;
+    int worker_is_initialized;
+    proxy_worker_stat *slot;
 
     workers = (proxy_worker *)balancer->workers->elts;
 
     for (i = 0; i < balancer->workers->nelts; i++) {
+        worker_is_initialized = PROXY_WORKER_IS_INITIALIZED(workers);
+        if (!worker_is_initialized) {
+            /*
+             * If the worker is not initialized check whether its scoreboard
+             * slot is already initialized.
+             */
+            slot = (proxy_worker_stat *) ap_get_scoreboard_lb(workers->id);
+            if (slot) {
+                worker_is_initialized = slot->status & PROXY_WORKER_INITIALIZED;
+            }
+            else {
+                worker_is_initialized = 0;
+            }
+        }
         ap_proxy_initialize_worker_share(conf, workers, s);
         ap_proxy_initialize_worker(workers, s);
+        if (!worker_is_initialized) {
+            /* Set to the original configuration */
+            workers->s->lbstatus = workers->s->lbfactor =
+            (workers->lbfactor ? workers->lbfactor : 1);
+            workers->s->lbset = workers->lbset;
+        }
         ++workers;
     }
 
-    workers = (proxy_worker *)balancer->workers->elts;
-    for (i = 0; i < balancer->workers->nelts; i++) {
-        /* Set to the original configuration */
-        workers[i].s->lbstatus = workers[i].s->lbfactor =
-          (workers[i].lbfactor ? workers[i].lbfactor : 1);
-        workers[i].s->lbset = workers[i].lbset;
-    }
     /* Set default number of attempts to the number of
      * workers.
      */
index 26fa308e0fb79ab6062a5bd30ef955dd2610480b..05ec5da56db6975f48ca28cf2122a25e1883ca39 100644 (file)
@@ -1650,7 +1650,7 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf,
     void *score = NULL;
 #endif
 
-    if (worker->s && PROXY_WORKER_IS_INITIALIZED(worker)) {
+    if (PROXY_WORKER_IS_INITIALIZED(worker)) {
         /* The worker share is already initialized */
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
               "proxy: worker %s already initialized",