summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorJim Jagielski <jim@apache.org>2011-02-01 20:07:02 +0100
committerJim Jagielski <jim@apache.org>2011-02-01 20:07:02 +0100
commitf2c6805bc9a7d5eac6ab9004ae75af131e9999b0 (patch)
tree4cdc41ce93bdd272f7ba6a9685a3254cac21c505 /modules
parentbitfields should be unsigned (diff)
downloadapache2-f2c6805bc9a7d5eac6ab9004ae75af131e9999b0.tar.xz
apache2-f2c6805bc9a7d5eac6ab9004ae75af131e9999b0.zip
Again, abstract out the worker status magic to it's handled
by funcs... git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1066138 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--modules/proxy/mod_proxy.c2
-rw-r--r--modules/proxy/mod_proxy.h19
-rw-r--r--modules/proxy/mod_proxy_balancer.c13
-rw-r--r--modules/proxy/proxy_util.c62
4 files changed, 74 insertions, 22 deletions
diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c
index 158d4e834b..32b97cebe5 100644
--- a/modules/proxy/mod_proxy.c
+++ b/modules/proxy/mod_proxy.c
@@ -210,7 +210,7 @@ static const char *set_worker_param(apr_pool_t *p,
mode = 0;
v++;
}
- rv = ap_proxy_set_wstatus(*v, mode, &worker->s->status);
+ rv = ap_proxy_set_wstatus(*v, mode, worker);
if (rv != APR_SUCCESS)
return "Unknown status parameter option";
}
diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h
index 2016cccb1c..b035b12c4f 100644
--- a/modules/proxy/mod_proxy.h
+++ b/modules/proxy/mod_proxy.h
@@ -824,12 +824,21 @@ PROXY_DECLARE(unsigned int) ap_proxy_hashfunc(const char *str, proxy_hash_t meth
/**
* 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
+ * @param c flag
+ * @param set set or unset bit
+ * @param w worker to use
+ * @return APR_SUCCESS if valid flag
*/
-PROXY_DECLARE(apr_status_t) ap_proxy_set_wstatus(char c, int set, unsigned int *status);
+PROXY_DECLARE(apr_status_t) ap_proxy_set_wstatus(char c, int set, proxy_worker *w);
+
+
+/**
+ * Create readable representation of worker status bitfield
+ * @param p pool
+ * @param w worker to use
+ * @return string representation of status
+ */
+PROXY_DECLARE(char *) ap_proxy_parse_wstatus(apr_pool_t *p, proxy_worker *w);
#define PROXY_LBMETHOD "proxylbmethod"
diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c
index f3f2c71535..8ea81c9378 100644
--- a/modules/proxy/mod_proxy_balancer.c
+++ b/modules/proxy/mod_proxy_balancer.c
@@ -1046,18 +1046,7 @@ static int balancer_handler(request_rec *r)
ap_escape_html(r->pool, worker->s->redirect), NULL);
ap_rprintf(r, "</td><td align=\"center\">%d</td>", worker->s->lbfactor);
ap_rprintf(r, "<td align=\"center\">%d</td><td align=\"center\">", worker->s->lbset);
- if (worker->s->status & PROXY_WORKER_DISABLED)
- ap_rputs("Dis ", r);
- if (worker->s->status & PROXY_WORKER_IN_ERROR)
- ap_rputs("Err ", r);
- if (worker->s->status & PROXY_WORKER_STOPPED)
- ap_rputs("Stop ", r);
- if (worker->s->status & PROXY_WORKER_HOT_STANDBY)
- ap_rputs("Stby ", r);
- if (PROXY_WORKER_IS_USABLE(worker))
- ap_rputs("Ok", r);
- if (!PROXY_WORKER_IS_INITIALIZED(worker))
- ap_rputs("-", r);
+ ap_rvputs(r, ap_proxy_parse_wstatus(r->pool, worker), NULL);
ap_rputs("</td>", r);
ap_rprintf(r, "<td align=\"center\">%" APR_SIZE_T_FMT "</td><td align=\"center\">", worker->s->elected);
ap_rputs(apr_strfsize(worker->s->transferred, fbuf), r);
diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c
index 02c8e9ed16..6e0f2ce049 100644
--- a/modules/proxy/proxy_util.c
+++ b/modules/proxy/proxy_util.c
@@ -2834,10 +2834,35 @@ ap_proxy_hashfunc(const char *str, proxy_hash_t method)
}
}
-PROXY_DECLARE(apr_status_t) ap_proxy_set_wstatus(const char c, int set, unsigned int *status)
+PROXY_DECLARE(apr_status_t) ap_proxy_set_wstatus(const char c, int set, proxy_worker *w)
{
+ unsigned int *status = &w->s->status;
char bit = toupper(c);
switch (bit) {
+ case PROXY_WORKER_INITIALIZED_FLAG :
+ if (set)
+ *status |= PROXY_WORKER_INITIALIZED;
+ else
+ *status &= ~PROXY_WORKER_INITIALIZED;
+ break;
+ case PROXY_WORKER_IGNORE_ERRORS_FLAG :
+ if (set)
+ *status |= PROXY_WORKER_IGNORE_ERRORS;
+ else
+ *status &= ~PROXY_WORKER_IGNORE_ERRORS;
+ break;
+ case PROXY_WORKER_DRAIN_FLAG :
+ if (set)
+ *status |= PROXY_WORKER_DRAIN;
+ else
+ *status &= ~PROXY_WORKER_DRAIN;
+ break;
+ case PROXY_WORKER_IN_SHUTDOWN_FLAG :
+ if (set)
+ *status |= PROXY_WORKER_IN_SHUTDOWN;
+ else
+ *status &= ~PROXY_WORKER_IN_SHUTDOWN;
+ break;
case PROXY_WORKER_DISABLED_FLAG :
if (set)
*status |= PROXY_WORKER_DISABLED;
@@ -2862,11 +2887,11 @@ PROXY_DECLARE(apr_status_t) ap_proxy_set_wstatus(const char c, int set, unsigned
else
*status &= ~PROXY_WORKER_HOT_STANDBY;
break;
- case PROXY_WORKER_IGNORE_ERRORS_FLAG :
+ case PROXY_WORKER_FREE_FLAG :
if (set)
- *status |= PROXY_WORKER_IGNORE_ERRORS;
+ *status |= PROXY_WORKER_FREE;
else
- *status &= ~PROXY_WORKER_IGNORE_ERRORS;
+ *status &= ~PROXY_WORKER_FREE;
break;
default:
return APR_EINVAL;
@@ -2874,3 +2899,32 @@ PROXY_DECLARE(apr_status_t) ap_proxy_set_wstatus(const char c, int set, unsigned
}
return APR_SUCCESS;
}
+
+PROXY_DECLARE(char *) ap_proxy_parse_wstatus(apr_pool_t *p, proxy_worker *w)
+{
+ char *ret = NULL;
+ unsigned int status = w->s->status;
+ if (status & PROXY_WORKER_INITIALIZED)
+ ret = apr_pstrcat(p, "Init ", NULL);
+ else
+ ret = apr_pstrcat(p, "!Init ", NULL);
+ if (status & PROXY_WORKER_IGNORE_ERRORS)
+ ret = apr_pstrcat(p, ret, "Ign ", NULL);
+ if (status & PROXY_WORKER_DRAIN)
+ ret = apr_pstrcat(p, ret, "Drn ", NULL);
+ if (status & PROXY_WORKER_IN_SHUTDOWN)
+ ret = apr_pstrcat(p, ret, "Shut ", NULL);
+ if (status & PROXY_WORKER_DISABLED)
+ ret = apr_pstrcat(p, ret, "Dis ", NULL);
+ if (status & PROXY_WORKER_STOPPED)
+ ret = apr_pstrcat(p, ret, "Stop ", NULL);
+ if (status & PROXY_WORKER_IN_ERROR)
+ ret = apr_pstrcat(p, ret, "Err ", NULL);
+ if (status & PROXY_WORKER_HOT_STANDBY)
+ ret = apr_pstrcat(p, ret, "Stby ", NULL);
+ if (status & PROXY_WORKER_FREE)
+ ret = apr_pstrcat(p, ret, "Free ", NULL);
+ if (PROXY_WORKER_IS_USABLE(w))
+ ret = apr_pstrcat(p, ret, "Ok ", NULL);
+ return ret;
+}