From 7b9391e010b4b196801624c0dd708b3794c2a665 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Tue, 11 Jul 2006 19:32:36 +0000 Subject: [PATCH] Clean up some proxy macros. Avoid the use of magic numbers, and instead use pre-defined defines. Also, ensure that usable workers have been initialized :) Allocate a bit for hot standbys. Adjust so that normal "usable" workers don't count these. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@420954 13f79535-47bb-0310-9956-ffa450edef68 --- modules/proxy/mod_proxy.h | 23 +++++++++++++++++++++-- modules/proxy/proxy_util.c | 6 +++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 57a7076b35..a938586ece 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -241,15 +241,34 @@ struct proxy_conn_pool { proxy_conn_rec *conn; /* Single connection for prefork mpm's */ }; -/* woker status flags */ +/* worker status flags */ #define PROXY_WORKER_INITIALIZED 0x0001 #define PROXY_WORKER_IGNORE_ERRORS 0x0002 #define PROXY_WORKER_IN_SHUTDOWN 0x0010 #define PROXY_WORKER_DISABLED 0x0020 #define PROXY_WORKER_STOPPED 0x0040 #define PROXY_WORKER_IN_ERROR 0x0080 +#define PROXY_WORKER_HOT_STANDBY 0x0100 -#define PROXY_WORKER_IS_USABLE(f) (!((f)->s->status & 0x00F0)) +#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 ) + +#define PROXY_WORKER_IS_STANDBY(f) ( (f)->s->status & \ + PROXY_WORKER_HOT_STANDBY ) + +#define PROXY_WORKER_IS_USABLE(f) ( !((f)->s->status & \ + (PROXY_WORKER_NOT_USABLE_BITMAP | PROXY_WORKER_HOT_STANDBY )) && \ + PROXY_WORKER_IS_INITIALIZED(f) ) + +#define PROXY_WORKER_IS_USABLE_STANDBY(f) ( !((f)->s->status & \ + PROXY_WORKER_NOT_USABLE_BITMAP) && PROXY_WORKER_IS_STANDBY(f) && \ + PROXY_WORKER_IS_INITIALIZED(f) ) + +#define PROXY_WORKER_IS_USABLE_DC(f) ( !((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/proxy_util.c b/modules/proxy/proxy_util.c index d83d22bdfe..93340bbe3f 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -1605,7 +1605,7 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf, void *score = NULL; #endif - if (worker->s && (worker->s->status & PROXY_WORKER_INITIALIZED)) { + if (worker->s && 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", @@ -1639,7 +1639,7 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf, * recheck to see if we've already been here. Possible * if proxy is using scoreboard to hold shared stats */ - if (worker->s->status & PROXY_WORKER_INITIALIZED) { + 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", @@ -1667,7 +1667,7 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, ser int mpm_threads; #endif - if (worker->status & PROXY_WORKER_INITIALIZED) { + if (PROXY_WORKER_IS_INITIALIZED(worker)) { /* The worker is already initialized */ return APR_SUCCESS; } -- 2.40.0