Commit 9232412b authored by Jim Jagielski's avatar Jim Jagielski
Browse files

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
parent 5498665b
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -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
+3 −3
Original line number Diff line number Diff line
@@ -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;
    }