httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1207926 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.c mod_proxy.h mod_proxy_balancer.c proxy_util.c
Date Tue, 29 Nov 2011 15:36:13 GMT
Author: jim
Date: Tue Nov 29 15:36:11 2011
New Revision: 1207926

URL: http://svn.apache.org/viewvc?rev=1207926&view=rev
Log:
Logic which makes the balancer "active" or not... so we can turn them
off and on as needed.

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=1207926&r1=1207925&r2=1207926&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Tue Nov 29 15:36:11 2011
@@ -1449,7 +1449,7 @@ static const char *
     elts = (const apr_table_entry_t *)arr->elts;
     /* Distinguish the balancer from worker */
     if (ap_proxy_valid_balancer_name(r, 9)) {
-        proxy_balancer *balancer = ap_proxy_get_balancer(cmd->pool, conf, r);
+        proxy_balancer *balancer = ap_proxy_get_balancer(cmd->pool, conf, r, 0);
         if (!balancer) {
             const char *err = ap_proxy_define_balancer(cmd->pool, &balancer, conf,
r, f, 0);
             if (err)
@@ -1905,7 +1905,7 @@ static const char *add_member(cmd_parms 
     ap_str_tolower(path);   /* lowercase scheme://hostname */
 
     /* Try to find the balancer */
-    balancer = ap_proxy_get_balancer(cmd->temp_pool, conf, path);
+    balancer = ap_proxy_get_balancer(cmd->temp_pool, conf, path, 0);
     if (!balancer) {
         err = ap_proxy_define_balancer(cmd->pool, &balancer, conf, path, "/", 0);
         if (err)
@@ -1985,7 +1985,7 @@ static const char *
     }
 
     if (ap_proxy_valid_balancer_name(name, 9)) {
-        balancer = ap_proxy_get_balancer(cmd->pool, conf, name);
+        balancer = ap_proxy_get_balancer(cmd->pool, conf, name, 0);
         if (!balancer) {
             if (in_proxy_section) {
                 err = ap_proxy_define_balancer(cmd->pool, &balancer, conf, name, "/",
0);
@@ -2134,7 +2134,7 @@ static const char *proxysection(cmd_parm
                                "> arguments are not supported for non url.",
                                NULL);
         if (ap_proxy_valid_balancer_name((char *)conf->p, 9)) {
-            balancer = ap_proxy_get_balancer(cmd->pool, sconf, conf->p);
+            balancer = ap_proxy_get_balancer(cmd->pool, sconf, conf->p, 0);
             if (!balancer) {
                 err = ap_proxy_define_balancer(cmd->pool, &balancer,
                                                sconf, conf->p, "/", 0);

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=1207926&r1=1207925&r2=1207926&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Tue Nov 29 15:36:11 2011
@@ -639,11 +639,13 @@ PROXY_DECLARE(int) ap_proxy_valid_balanc
  * @param p     memory pool used for temporary storage while finding balancer
  * @param conf  current proxy server configuration
  * @param url   url to find the worker from; must have balancer:// prefix
+ * @param careactive true if we care if the balancer is active or not
  * @return      proxy_balancer or NULL if not found
  */
 PROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
                                                       proxy_server_conf *conf,
-                                                      const char *url);
+                                                      const char *url,
+                                                      int careactive);
 
 /**
  * Update the balancer's vhost related fields

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=1207926&r1=1207925&r2=1207926&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c Tue Nov 29 15:36:11 2011
@@ -452,7 +452,7 @@ static int proxy_balancer_pre_request(pr
      * for balancer, because this is failover attempt.
      */
     if (!*balancer &&
-        !(*balancer = ap_proxy_get_balancer(r->pool, conf, *url)))
+        !(*balancer = ap_proxy_get_balancer(r->pool, conf, *url, 1)))
         return DECLINED;
 
     /* Step 2: Lock the LoadBalancer
@@ -951,7 +951,7 @@ static int balancer_handler(request_rec 
     }
     if ((name = apr_table_get(params, "b")))
         bsel = ap_proxy_get_balancer(r->pool, conf,
-            apr_pstrcat(r->pool, BALANCER_PREFIX, name, NULL));
+            apr_pstrcat(r->pool, BALANCER_PREFIX, name, NULL), 0);
 
     if ((name = apr_table_get(params, "w"))) {
         wsel = ap_proxy_get_worker(r->pool, bsel, conf, name);
@@ -1201,7 +1201,7 @@ static int balancer_handler(request_rec 
             ap_rvputs(r, balancer->s->name, "</a></h3>\n", NULL);
             ap_rputs("\n\n<table border='0' style='text-align: left;'><tr>"
                 "<th>MaxMembers</th><th>StickySession</th><th>DisableFailover</th><th>Timeout</th><th>FailoverAttempts</th><th>Method</th>"
-                "<th>Path</th></tr>\n<tr>", r);
+                "<th>Path</th><th>Active</th></tr>\n<tr>",
r);
             /* the below is a safe cast, since the number of slots total will
              * never be more than max_workers, which is restricted to int */
             ap_rprintf(r, "<td align='center'>%d [%d Used]</td>\n", balancer->max_workers,
@@ -1230,6 +1230,8 @@ static int balancer_handler(request_rec 
                 ap_rvputs(r, balancer->s->vhost, " -> ", NULL);
             }
             ap_rvputs(r, balancer->s->vpath, "</td>\n", NULL);
+            ap_rprintf(r, "<td align='center'>%s</td>\n",
+                       !balancer->s->inactive ? "Yes" : "No");
             ap_rputs("</table>\n<br />", r);
             ap_rputs("\n\n<table border='0' style='text-align: left;'><tr>"
                 "<th>Worker URL</th>"

Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=1207926&r1=1207925&r2=1207926&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Tue Nov 29 15:36:11 2011
@@ -1091,7 +1091,7 @@ PROXY_DECLARE(const char *) ap_proxy_loc
          * to find which member actually handled this request.
          */
         if (ap_proxy_valid_balancer_name((char *)real, 0) &&
-            (balancer = ap_proxy_get_balancer(r->pool, sconf, real))) {
+            (balancer = ap_proxy_get_balancer(r->pool, sconf, real, 1))) {
             int n, l3 = 0;
             proxy_worker **worker = (proxy_worker **)balancer->workers->elts;
             const char *urlpart = ap_strchr_c(real, '/');
@@ -1292,7 +1292,8 @@ PROXY_DECLARE(int) ap_proxy_valid_balanc
 
 PROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
                                                       proxy_server_conf *conf,
-                                                      const char *url)
+                                                      const char *url,
+                                                      int care)
 {
     proxy_balancer *balancer;
     char *c, *uri = apr_pstrdup(p, url);
@@ -1309,7 +1310,9 @@ PROXY_DECLARE(proxy_balancer *) ap_proxy
     balancer = (proxy_balancer *)conf->balancers->elts;
     for (i = 0; i < conf->balancers->nelts; i++) {
         if (strcasecmp(balancer->s->name, uri) == 0) {
-            return balancer;
+            if (!care || !balancer->s->inactive) {
+                return balancer;
+            }
         }
         balancer++;
     }



Mime
View raw message