You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2011/02/01 19:13:15 UTC
svn commit: r1066110 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.c
mod_proxy.h proxy_util.c
Author: jim
Date: Tue Feb 1 18:13:15 2011
New Revision: 1066110
URL: http://svn.apache.org/viewvc?rev=1066110&view=rev
Log:
Move the setting of flags into a func... that way there is
one place to maintain as the number of flags grow...
Since we are using just the bits, make unsigned.
Modified:
httpd/httpd/trunk/modules/proxy/mod_proxy.c
httpd/httpd/trunk/modules/proxy/mod_proxy.h
httpd/httpd/trunk/modules/proxy/proxy_util.c
Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=1066110&r1=1066109&r2=1066110&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Tue Feb 1 18:13:15 2011
@@ -198,6 +198,7 @@ static const char *set_worker_param(apr_
else if (!strcasecmp(key, "status")) {
const char *v;
int mode = 1;
+ apr_status_t rv;
/* Worker status.
*/
for (v = val; *v; v++) {
@@ -209,39 +210,9 @@ static const char *set_worker_param(apr_
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")) {
Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=1066110&r1=1066109&r2=1066110&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Tue Feb 1 18:13:15 2011
@@ -254,7 +254,7 @@ struct proxy_conn_pool {
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
@@ -265,6 +265,17 @@ struct proxy_conn_pool {
#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 )
@@ -296,7 +307,6 @@ typedef struct {
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 */
@@ -306,6 +316,7 @@ typedef struct {
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,
@@ -348,11 +359,11 @@ typedef struct {
/* 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 */
};
@@ -810,6 +821,16 @@ typedef enum { PROXY_HASHFUNC_DEFAULT, P
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.
Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=1066110&r1=1066109&r2=1066110&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Tue Feb 1 18:13:15 2011
@@ -2833,3 +2833,44 @@ ap_proxy_hashfunc(const char *str, proxy
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;
+}