httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1066138 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.c mod_proxy.h mod_proxy_balancer.c proxy_util.c
Date Tue, 01 Feb 2011 19:07:02 GMT
Author: jim
Date: Tue Feb  1 19:07:02 2011
New Revision: 1066138

URL: http://svn.apache.org/viewvc?rev=1066138&view=rev
Log:
Again, abstract out the worker status magic to it's handled
by funcs...

Modified:
    httpd/httpd/trunk/modules/proxy/mod_proxy.c
    httpd/httpd/trunk/modules/proxy/mod_proxy.h
    httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c
    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=1066138&r1=1066137&r2=1066138&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Tue Feb  1 19:07:02 2011
@@ -210,7 +210,7 @@ static const char *set_worker_param(apr_
                 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";
         }

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=1066138&r1=1066137&r2=1066138&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Tue Feb  1 19:07:02 2011
@@ -824,12 +824,21 @@ PROXY_DECLARE(unsigned int) ap_proxy_has
 
 /**
  * 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"
 

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c?rev=1066138&r1=1066137&r2=1066138&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c Tue Feb  1 19:07:02 2011
@@ -1046,18 +1046,7 @@ static int balancer_handler(request_rec 
                           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);

Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=1066138&r1=1066137&r2=1066138&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Tue Feb  1 19:07:02 2011
@@ -2834,10 +2834,35 @@ ap_proxy_hashfunc(const char *str, proxy
     }
 }
 
-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
             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
     }
     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;
+}



Mime
View raw message