httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r575708 - in /httpd/httpd/branches/2.2.x/modules/proxy: mod_proxy.h mod_proxy_balancer.c proxy_util.c
Date Fri, 14 Sep 2007 14:47:55 GMT
Author: jim
Date: Fri Sep 14 07:47:54 2007
New Revision: 575708

URL: http://svn.apache.org/viewvc?rev=575708&view=rev
Log:
Merge r572937, r574485, r574486 from trunk:

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

Modified:
    httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy.h
    httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_balancer.c
    httpd/httpd/branches/2.2.x/modules/proxy/proxy_util.c

Modified: httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy.h?rev=575708&r1=575707&r2=575708&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy.h Fri Sep 14 07:47:54 2007
@@ -254,14 +254,16 @@
 #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

Modified: httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_balancer.c?rev=575708&r1=575707&r2=575708&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_balancer.c Fri Sep 14 07:47:54 2007
@@ -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 @@
 {
     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.
      */

Modified: httpd/httpd/branches/2.2.x/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/proxy/proxy_util.c?rev=575708&r1=575707&r2=575708&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/branches/2.2.x/modules/proxy/proxy_util.c Fri Sep 14 07:47:54 2007
@@ -1650,7 +1650,7 @@
     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",



Mime
View raw message