From: Jim Jagielski Date: Fri, 14 Sep 2007 14:47:54 +0000 (+0000) Subject: Merge r572937, r574485, r574486 from trunk: X-Git-Tag: 2.2.7~406 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1456a9f3dbcf315de316075800078bacd4a01d9a;p=thirdparty%2Fapache%2Fhttpd.git 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 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@575708 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index e7879525611..8e2c5066c22 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -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 diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index e2f22235cf6..966f259e23c 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -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. */ diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index 26fa308e0fb..05ec5da56db 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -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",