else if (!strcasecmp(key, "status")) {
const char *v;
int mode = 1;
+ apr_status_t rv;
/* Worker status.
*/
for (v = val; *v; v++) {
mode = 0;
v++;
}
- if (*v == 'D' || *v == 'd') {
- if (mode)
- worker->s->status |= PROXY_WORKER_DISABLED;
- else
- worker->s->status &= ~PROXY_WORKER_DISABLED;
- }
- else if (*v == 'S' || *v == 's') {
- if (mode)
- worker->s->status |= PROXY_WORKER_STOPPED;
- else
- worker->s->status &= ~PROXY_WORKER_STOPPED;
- }
- else if (*v == 'E' || *v == 'e') {
- if (mode)
- worker->s->status |= PROXY_WORKER_IN_ERROR;
- else
- worker->s->status &= ~PROXY_WORKER_IN_ERROR;
- }
- else if (*v == 'H' || *v == 'h') {
- if (mode)
- worker->s->status |= PROXY_WORKER_HOT_STANDBY;
- else
- worker->s->status &= ~PROXY_WORKER_HOT_STANDBY;
- }
- else if (*v == 'I' || *v == 'i') {
- if (mode)
- worker->s->status |= PROXY_WORKER_IGNORE_ERRORS;
- else
- worker->s->status &= ~PROXY_WORKER_IGNORE_ERRORS;
- }
- else {
+ rv = ap_proxy_set_wstatus(*v, mode, &worker->s->status);
+ if (rv != APR_SUCCESS)
return "Unknown status parameter option";
- }
}
}
else if (!strcasecmp(key, "flushpackets")) {
proxy_conn_rec *conn; /* Single connection for prefork mpm */
};
-/* worker status flags */
+/* worker status bits */
#define PROXY_WORKER_INITIALIZED 0x0001
#define PROXY_WORKER_IGNORE_ERRORS 0x0002
#define PROXY_WORKER_DRAIN 0x0004
#define PROXY_WORKER_HOT_STANDBY 0x0100
#define PROXY_WORKER_FREE 0x0200
+/* worker status flags */
+#define PROXY_WORKER_INITIALIZED_FLAG 'O'
+#define PROXY_WORKER_IGNORE_ERRORS_FLAG 'I'
+#define PROXY_WORKER_DRAIN_FLAG 'N'
+#define PROXY_WORKER_IN_SHUTDOWN_FLAG 'U'
+#define PROXY_WORKER_DISABLED_FLAG 'D'
+#define PROXY_WORKER_STOPPED_FLAG 'S'
+#define PROXY_WORKER_IN_ERROR_FLAG 'E'
+#define PROXY_WORKER_HOT_STANDBY_FLAG 'H'
+#define PROXY_WORKER_FREE_FLAG 'F'
+
#define PROXY_WORKER_NOT_USABLE_BITMAP ( PROXY_WORKER_IN_SHUTDOWN | \
PROXY_WORKER_DISABLED | PROXY_WORKER_STOPPED | PROXY_WORKER_IN_ERROR )
char redirect[PROXY_WORKER_MAX_ROUTE_SIZE]; /* temporary balancing redirection route */
char flusher[PROXY_WORKER_MAX_SCHEME_SIZE]; /* flush provider used by mod_proxy_fdpass */
int lbset; /* load balancer cluster set */
- int status;
int retries; /* number of retries on this worker */
int lbstatus; /* Current lbstatus */
int lbfactor; /* dynamic lbfactor */
int flush_wait; /* poll wait time in microseconds if flush_auto */
int index; /* shm array index */
unsigned int hash; /* hash of worker name */
+ unsigned int status; /* worker status bitfield */
enum {
flush_off,
flush_on,
/* Worker configuration */
struct proxy_worker {
unsigned int hash; /* hash of worker name */
+ unsigned int local_status; /* status of per-process worker */
proxy_conn_pool *cp; /* Connection pool to use */
proxy_worker_shared *s; /* Shared data */
proxy_balancer *balancer; /* which balancer am I in? */
apr_thread_mutex_t *mutex; /* Thread lock for updating address cache */
- int local_status; /* status of per-process worker */
void *context; /* general purpose storage */
};
PROXY_DECLARE(unsigned int) ap_proxy_hashfunc(const char *str, proxy_hash_t method);
+
+/**
+ * Set/unset the worker status bitfield depending on flag
+ * @param c flag
+ * @param set set or unset bit
+ * @param status bitfield to use
+ * @return APR_SUCCESS if valid flag
+ */
+PROXY_DECLARE(apr_status_t) ap_proxy_set_wstatus(char c, int set, unsigned int *status);
+
#define PROXY_LBMETHOD "proxylbmethod"
/* The number of dynamic workers that can be added when reconfiguring.
return hash;
}
}
+
+PROXY_DECLARE(apr_status_t) ap_proxy_set_wstatus(const char c, int set, unsigned int *status)
+{
+ char bit = toupper(c);
+ switch (bit) {
+ case PROXY_WORKER_DISABLED_FLAG :
+ if (set)
+ *status |= PROXY_WORKER_DISABLED;
+ else
+ *status &= ~PROXY_WORKER_DISABLED;
+ break;
+ case PROXY_WORKER_STOPPED_FLAG :
+ if (set)
+ *status |= PROXY_WORKER_STOPPED;
+ else
+ *status &= ~PROXY_WORKER_STOPPED;
+ break;
+ case PROXY_WORKER_IN_ERROR_FLAG :
+ if (set)
+ *status |= PROXY_WORKER_IN_ERROR;
+ else
+ *status &= ~PROXY_WORKER_IN_ERROR;
+ break;
+ case PROXY_WORKER_HOT_STANDBY_FLAG :
+ if (set)
+ *status |= PROXY_WORKER_HOT_STANDBY;
+ else
+ *status &= ~PROXY_WORKER_HOT_STANDBY;
+ break;
+ case PROXY_WORKER_IGNORE_ERRORS_FLAG :
+ if (set)
+ *status |= PROXY_WORKER_IGNORE_ERRORS;
+ else
+ *status &= ~PROXY_WORKER_IGNORE_ERRORS;
+ break;
+ default:
+ return APR_EINVAL;
+ break;
+ }
+ return APR_SUCCESS;
+}