httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1206286 - in /httpd/httpd/trunk/modules/proxy: balancers/mod_lbmethod_bybusyness.c balancers/mod_lbmethod_byrequests.c balancers/mod_lbmethod_bytraffic.c mod_proxy.c mod_proxy.h mod_proxy_balancer.c proxy_util.c
Date Fri, 25 Nov 2011 19:28:15 GMT
Author: jim
Date: Fri Nov 25 19:28:14 2011
New Revision: 1206286

URL: http://svn.apache.org/viewvc?rev=1206286&view=rev
Log:
Move useful and shared balancer stuff to the shm slot...
Provide hooks for post-config/runtime addition of
balancers.

Modified:
    httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_bybusyness.c
    httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_byrequests.c
    httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_bytraffic.c
    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/balancers/mod_lbmethod_bybusyness.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_bybusyness.c?rev=1206286&r1=1206285&r2=1206286&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_bybusyness.c (original)
+++ httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_bybusyness.c Fri Nov 25 19:28:14
2011
@@ -38,7 +38,7 @@ static proxy_worker *find_best_bybusynes
 
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                  "proxy: Entering bybusyness for BALANCER (%s)",
-                 balancer->name);
+                 balancer->s->name);
 
     /* First try to see if we have available candidate */
     do {

Modified: httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_byrequests.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_byrequests.c?rev=1206286&r1=1206285&r2=1206286&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_byrequests.c (original)
+++ httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_byrequests.c Fri Nov 25 19:28:14
2011
@@ -82,7 +82,7 @@ static proxy_worker *find_best_byrequest
 
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                  "proxy: Entering byrequests for BALANCER (%s)",
-                 balancer->name);
+                 balancer->s->name);
 
     /* First try to see if we have available candidate */
     do {

Modified: httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_bytraffic.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_bytraffic.c?rev=1206286&r1=1206285&r2=1206286&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_bytraffic.c (original)
+++ httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_bytraffic.c Fri Nov 25 19:28:14
2011
@@ -54,7 +54,7 @@ static proxy_worker *find_best_bytraffic
 
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                  "proxy: Entering bytraffic for BALANCER (%s)",
-                 balancer->name);
+                 balancer->s->name);
 
     /* First try to see if we have available candidate */
     do {

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=1206286&r1=1206285&r2=1206286&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Fri Nov 25 19:28:14 2011
@@ -1450,7 +1450,7 @@ static const char *
     if (ap_proxy_valid_balancer_name(r, 9)) {
         proxy_balancer *balancer = ap_proxy_get_balancer(cmd->pool, conf, r);
         if (!balancer) {
-            const char *err = ap_proxy_define_balancer(cmd->pool, &balancer, conf,
r, 0);
+            const char *err = ap_proxy_define_balancer(cmd->pool, &balancer, conf,
r, f, 0);
             if (err)
                 return apr_pstrcat(cmd->temp_pool, "ProxyPass ", err, NULL);
         }
@@ -1903,7 +1903,7 @@ static const char *add_member(cmd_parms 
     /* Try to find the balancer */
     balancer = ap_proxy_get_balancer(cmd->temp_pool, conf, path);
     if (!balancer) {
-        err = ap_proxy_define_balancer(cmd->pool, &balancer, conf, path, 0);
+        err = ap_proxy_define_balancer(cmd->pool, &balancer, conf, path, "/", 0);
         if (err)
             return apr_pstrcat(cmd->temp_pool, "BalancerMember ", err, NULL);
     }
@@ -1913,12 +1913,12 @@ static const char *add_member(cmd_parms 
     if (!worker) {
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, cmd->server,
                      "Defining worker '%s' for balancer '%s'",
-                     name, balancer->name);
+                     name, balancer->s->name);
         if ((err = ap_proxy_define_worker(cmd->pool, &worker, balancer, conf, name,
0)) != NULL)
             return apr_pstrcat(cmd->temp_pool, "BalancerMember ", err, NULL);
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, cmd->server,
                      "Defined worker '%s' for balancer '%s'",
-                     worker->s->name, balancer->name);
+                     worker->s->name, balancer->s->name);
         PROXY_COPY_CONF_PARAMS(worker, conf);
     } else {
         reuse = 1;
@@ -1984,7 +1984,7 @@ static const char *
         balancer = ap_proxy_get_balancer(cmd->pool, conf, name);
         if (!balancer) {
             if (in_proxy_section) {
-                err = ap_proxy_define_balancer(cmd->pool, &balancer, conf, name, 0);
+                err = ap_proxy_define_balancer(cmd->pool, &balancer, conf, name, "/",
0);
                 if (err)
                     return apr_pstrcat(cmd->temp_pool, "ProxySet ",
                                        err, NULL);
@@ -2133,7 +2133,7 @@ static const char *proxysection(cmd_parm
             balancer = ap_proxy_get_balancer(cmd->pool, sconf, conf->p);
             if (!balancer) {
                 err = ap_proxy_define_balancer(cmd->pool, &balancer,
-                                               sconf, conf->p, 0);
+                                               sconf, conf->p, "/", 0);
                 if (err)
                     return apr_pstrcat(cmd->temp_pool, thiscmd->name,
                                        " ", err, NULL);
@@ -2327,7 +2327,7 @@ static int proxy_status_hook(request_rec
     balancer = (proxy_balancer *)conf->balancers->elts;
     for (i = 0; i < conf->balancers->nelts; i++) {
         ap_rputs("<hr />\n<h1>Proxy LoadBalancer Status for ", r);
-        ap_rvputs(r, balancer->name, "</h1>\n\n", NULL);
+        ap_rvputs(r, balancer->s->name, "</h1>\n\n", NULL);
         ap_rputs("\n\n<table border=\"0\"><tr>"
                  "<th>SSes</th><th>Timeout</th><th>Method</th>"
                  "</tr>\n<tr>", r);

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=1206286&r1=1206285&r2=1206286&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Fri Nov 25 19:28:14 2011
@@ -304,9 +304,11 @@ PROXY_WORKER_DISABLED | PROXY_WORKER_STO
 #endif
 #ifndef PROXY_WORKER_MAX_NAME_SIZE
 #define PROXY_WORKER_MAX_NAME_SIZE      96
+#define PROXY_BALANCER_MAX_NAME_SIZE PROXY_WORKER_MAX_NAME_SIZE
 #endif
 #ifndef PROXY_WORKER_MAX_HOSTNAME_SIZE
 #define PROXY_WORKER_MAX_HOSTNAME_SIZE  64
+#define PROXY_BALANCER_MAX_HOSTNAME_SIZE PROXY_WORKER_MAX_HOSTNAME_SIZE
 #endif
 #ifndef PROXY_BALANCER_MAX_STICKY_SIZE
 #define PROXY_BALANCER_MAX_STICKY_SIZE  64
@@ -408,16 +410,21 @@ typedef struct {
     char      sticky_path[PROXY_BALANCER_MAX_STICKY_SIZE];     /* URL sticky session identifier
*/
     char      sticky[PROXY_BALANCER_MAX_STICKY_SIZE];          /* sticky session identifier
*/
     char      lbpname[PROXY_MAX_PROVIDER_NAME_SIZE];  /* lbmethod provider name */
-    char nonce[APR_UUID_FORMATTED_LENGTH + 1];
+    char      nonce[APR_UUID_FORMATTED_LENGTH + 1];
+    char      name[PROXY_BALANCER_MAX_NAME_SIZE];
+    char      sname[PROXY_BALANCER_MAX_NAME_SIZE];
+    char      alias[PROXY_BALANCER_MAX_NAME_SIZE];
     apr_interval_time_t timeout;  /* Timeout for waiting on free connection */
     apr_time_t      wupdated;     /* timestamp of last change to workers list */
     int             max_attempts;     /* Number of attempts before failing */
     int             index;      /* shm array index */
+    int hash;
     unsigned int    sticky_force:1;   /* Disable failover for sticky sessions */
     unsigned int    scolonsep:1;      /* true if ';' seps sticky session paths */
     unsigned int    max_attempts_set:1;
     unsigned int    was_malloced:1;
     unsigned int    need_reset:1;
+    unsigned int    vhosted:1;
 } proxy_balancer_shared;
 
 #define ALIGNED_PROXY_BALANCER_SHARED_SIZE (APR_ALIGN_DEFAULT(sizeof(proxy_balancer_shared)))
@@ -429,12 +436,12 @@ struct proxy_balancer {
     ap_slotmem_provider_t *storage;
     int growth;                   /* number of post-config workers can added */
     int max_workers;              /* maximum number of allowed workers */
-    const char *name;             /* name of the load balancer */
-    const char *sname;            /* filesystem safe balancer name */
+    int hash;
     apr_time_t      wupdated;    /* timestamp of last change to workers list */
     proxy_balancer_method *lbmethod;
     apr_global_mutex_t  *gmutex; /* global lock for updating list of workers */
     apr_thread_mutex_t  *tmutex; /* Thread lock for updating shm */
+    proxy_server_conf *sconf;
     void            *context;    /* general purpose storage */
     proxy_balancer_shared *s;    /* Shared data */
 };
@@ -652,6 +659,7 @@ PROXY_DECLARE(proxy_balancer *) ap_proxy
  * @param balancer the new balancer
  * @param conf   current proxy server configuration
  * @param url    url containing balancer name
+ * @param alias  alias/fake-path to this balancer
  * @param do_malloc true if shared struct should be malloced
  * @return       error message or NULL if successfull
  */
@@ -659,6 +667,7 @@ PROXY_DECLARE(char *) ap_proxy_define_ba
                                                proxy_balancer **balancer,
                                                proxy_server_conf *conf,
                                                const char *url,
+                                               const char *alias,
                                                int do_malloc);
 
 /**

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=1206286&r1=1206285&r2=1206286&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c Fri Nov 25 19:28:14 2011
@@ -115,7 +115,7 @@ static void init_balancer_members(apr_po
         int worker_is_initialized;
         proxy_worker *worker = *workers;
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
-                     "Looking at %s -> %s initialized?", balancer->name, worker->s->name);
+                     "Looking at %s -> %s initialized?", balancer->s->name, worker->s->name);
         worker_is_initialized = PROXY_WORKER_IS_INITIALIZED(worker);
         if (!worker_is_initialized) {
             ap_proxy_initialize_worker(worker, s, p);
@@ -326,7 +326,7 @@ static proxy_worker *find_best_worker(pr
     if ((rv = PROXY_THREAD_LOCK(balancer)) != APR_SUCCESS) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                       "%s: Lock failed for find_best_worker()",
-                      balancer->name);
+                      balancer->s->name);
         return NULL;
     }
 
@@ -338,7 +338,7 @@ static proxy_worker *find_best_worker(pr
     if ((rv = PROXY_THREAD_UNLOCK(balancer)) != APR_SUCCESS) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                       "%s: Unlock failed for find_best_worker()",
-                      balancer->name);
+                      balancer->s->name);
     }
 
     if (candidate == NULL) {
@@ -429,7 +429,7 @@ static void force_recovery(proxy_balance
             (*worker)->s->status &= ~PROXY_WORKER_IN_ERROR;
             ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                          "%s: Forcing recovery for worker (%s)",
-                         balancer->name, (*worker)->s->hostname);
+                         balancer->s->name, (*worker)->s->hostname);
         }
     }
 }
@@ -460,7 +460,7 @@ static int proxy_balancer_pre_request(pr
      */
     if ((rv = PROXY_THREAD_LOCK(*balancer)) != APR_SUCCESS) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
-                      "%s: Lock failed for pre_request", (*balancer)->name);
+                      "%s: Lock failed for pre_request", (*balancer)->s->name);
         return DECLINED;
     }
 
@@ -522,11 +522,11 @@ static int proxy_balancer_pre_request(pr
         if (member_of) {
             ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                           "%s: All workers are in error state for route (%s)",
-                          (*balancer)->name, route);
+                          (*balancer)->s->name, route);
             if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) {
                 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                               "%s: Unlock failed for pre_request",
-                              (*balancer)->name);
+                              (*balancer)->s->name);
             }
             return HTTP_SERVICE_UNAVAILABLE;
         }
@@ -535,7 +535,7 @@ static int proxy_balancer_pre_request(pr
     if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                       "%s: Unlock failed for pre_request",
-                      (*balancer)->name);
+                      (*balancer)->s->name);
     }
     if (!*worker) {
         runtime = find_best_worker(*balancer, r);
@@ -543,11 +543,11 @@ static int proxy_balancer_pre_request(pr
             if ((*balancer)->workers->nelts) {
                 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                               "%s: All workers are in error state",
-                              (*balancer)->name);
+                              (*balancer)->s->name);
             } else {
                 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                               "%s: No workers in balancer",
-                              (*balancer)->name);
+                              (*balancer)->s->name);
             }
 
             return HTTP_SERVICE_UNAVAILABLE;
@@ -570,7 +570,7 @@ static int proxy_balancer_pre_request(pr
 
     /* Add balancer/worker info to env. */
     apr_table_setn(r->subprocess_env,
-                   "BALANCER_NAME", (*balancer)->name);
+                   "BALANCER_NAME", (*balancer)->s->name);
     apr_table_setn(r->subprocess_env,
                    "BALANCER_WORKER_NAME", (*worker)->s->name);
     apr_table_setn(r->subprocess_env,
@@ -595,7 +595,7 @@ static int proxy_balancer_pre_request(pr
     }
     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                   "%s: worker (%s) rewritten to %s",
-                  (*balancer)->name, (*worker)->s->name, *url);
+                  (*balancer)->s->name, (*worker)->s->name, *url);
 
     return access_status;
 }
@@ -611,7 +611,7 @@ static int proxy_balancer_post_request(p
     if ((rv = PROXY_THREAD_LOCK(balancer)) != APR_SUCCESS) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                       "%s: Lock failed for post_request",
-                      balancer->name);
+                      balancer->s->name);
         return HTTP_INTERNAL_SERVER_ERROR;
     }
 
@@ -623,7 +623,7 @@ static int proxy_balancer_post_request(p
                 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                               "%s:  Forcing recovery for worker (%s), "
                               "failonstatus %d",
-                              balancer->name, worker->s->name, val);
+                              balancer->s->name, worker->s->name, val);
                 worker->s->status |= PROXY_WORKER_IN_ERROR;
                 worker->s->error_time = apr_time_now();
                 break;
@@ -633,10 +633,10 @@ static int proxy_balancer_post_request(p
 
     if ((rv = PROXY_THREAD_UNLOCK(balancer)) != APR_SUCCESS) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
-                      "%s: Unlock failed for post_request", balancer->name);
+                      "%s: Unlock failed for post_request", balancer->s->name);
     }
     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
-                  "proxy_balancer_post_request for (%s)", balancer->name);
+                  "proxy_balancer_post_request for (%s)", balancer->s->name);
 
     if (worker && worker->s->busy)
         worker->s->busy--;
@@ -748,18 +748,14 @@ static int balancer_post_config(apr_pool
             unsigned int index;
 
             balancer->max_workers = balancer->workers->nelts + balancer->growth;
-            /* no need for the 'balancer://' prefix */
-            ap_pstr2_alnum(pconf, balancer->name + sizeof(BALANCER_PREFIX) - 1,
-                           &balancer->sname);
-            balancer->sname = apr_pstrcat(pconf, conf->id, "_", balancer->sname,
NULL);
 
             /* Create global mutex */
             rv = ap_global_mutex_create(&(balancer->gmutex), NULL, balancer_mutex_type,
-                                        balancer->sname, s, pconf, 0);
+                                        balancer->s->sname, s, pconf, 0);
             if (rv != APR_SUCCESS || !balancer->gmutex) {
                 ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
                              "mutex creation of %s : %s failed", balancer_mutex_type,
-                             balancer->sname);
+                             balancer->s->sname);
                 return HTTP_INTERNAL_SERVER_ERROR;
             }
 
@@ -783,11 +779,11 @@ static int balancer_post_config(apr_pool
 
             /* create slotmem slots for workers */
             ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "Doing workers create: %s (%s), %d,
%d",
-                         balancer->name, balancer->sname,
+                         balancer->s->name, balancer->s->sname,
                          (int)ALIGNED_PROXY_WORKER_SHARED_SIZE,
                          (int)balancer->max_workers);
 
-            rv = storage->create(&new, balancer->sname,
+            rv = storage->create(&new, balancer->s->sname,
                                  ALIGNED_PROXY_WORKER_SHARED_SIZE,
                                  balancer->max_workers, AP_SLOTMEM_TYPE_PREGRAB, pconf);
             if (rv != APR_SUCCESS) {
@@ -922,13 +918,13 @@ static int balancer_handler(request_rec 
         if ((rv = PROXY_THREAD_LOCK(balancer)) != APR_SUCCESS) {
             ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                           "%s: Lock failed for balancer_handler",
-                          balancer->name);
+                          balancer->s->name);
         }
         ap_proxy_sync_balancer(balancer, r->server, conf);
         if ((rv = PROXY_THREAD_UNLOCK(balancer)) != APR_SUCCESS) {
             ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                           "%s: Unlock failed for balancer_handler",
-                          balancer->name);
+                          balancer->s->name);
         }
     }
 
@@ -1088,7 +1084,7 @@ static int balancer_handler(request_rec 
                 if ((rv = PROXY_GLOBAL_LOCK(bsel)) != APR_SUCCESS) {
                     ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                                   "%s: Lock failed for adding worker",
-                                  bsel->name);
+                                  bsel->s->name);
                 }
                 ret = ap_proxy_define_worker(conf->pool, &nworker, bsel, conf, val,
0);
                 if (!ret) {
@@ -1101,7 +1097,7 @@ static int balancer_handler(request_rec 
                         if ((rv = PROXY_GLOBAL_UNLOCK(bsel)) != APR_SUCCESS) {
                             ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                                           "%s: Unlock failed for adding worker",
-                                          bsel->name);
+                                          bsel->s->name);
                         }
                         return HTTP_BAD_REQUEST;
                     }
@@ -1111,7 +1107,7 @@ static int balancer_handler(request_rec 
                         if ((rv = PROXY_GLOBAL_UNLOCK(bsel)) != APR_SUCCESS) {
                             ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                                           "%s: Unlock failed for adding worker",
-                                          bsel->name);
+                                          bsel->s->name);
                         }
                         return HTTP_BAD_REQUEST;
                     }
@@ -1121,7 +1117,7 @@ static int balancer_handler(request_rec 
                         if ((rv = PROXY_GLOBAL_UNLOCK(bsel)) != APR_SUCCESS) {
                             ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                                           "%s: Unlock failed for adding worker",
-                                          bsel->name);
+                                          bsel->s->name);
                         }
                         return HTTP_BAD_REQUEST;
                     }
@@ -1131,7 +1127,7 @@ static int balancer_handler(request_rec 
                         if ((rv = PROXY_GLOBAL_UNLOCK(bsel)) != APR_SUCCESS) {
                             ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                                           "%s: Unlock failed for adding worker",
-                                          bsel->name);
+                                          bsel->s->name);
                         }
                         return HTTP_BAD_REQUEST;
                     }
@@ -1143,7 +1139,7 @@ static int balancer_handler(request_rec 
                 if ((rv = PROXY_GLOBAL_UNLOCK(bsel)) != APR_SUCCESS) {
                     ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                                   "%s: Unlock failed for adding worker",
-                                  bsel->name);
+                                  bsel->s->name);
                 }
             }
 
@@ -1162,7 +1158,7 @@ static int balancer_handler(request_rec 
         balancer = (proxy_balancer *)conf->balancers->elts;
         for (i = 0; i < conf->balancers->nelts; i++) {
             ap_rputs("    <httpd:balancer>\n", r);
-            ap_rvputs(r, "      <httpd:name>", balancer->name, "</httpd:name>\n",
NULL);
+            ap_rvputs(r, "      <httpd:name>", balancer->s->name, "</httpd:name>\n",
NULL);
             ap_rputs("      <httpd:workers>\n", r);
             workers = (proxy_worker **)balancer->workers->elts;
             for (n = 0; n < balancer->workers->nelts; n++) {
@@ -1199,10 +1195,10 @@ static int balancer_handler(request_rec 
 
             ap_rputs("<hr />\n<h3>LoadBalancer Status for ", r);
             ap_rvputs(r, "<a href='", r->uri, "?b=",
-                      balancer->name + sizeof(BALANCER_PREFIX) - 1,
+                      balancer->s->name + sizeof(BALANCER_PREFIX) - 1,
                       "&nonce=", balancer->s->nonce,
                       "'>", NULL);
-            ap_rvputs(r, balancer->name, "</a></h3>\n\n", NULL);
+            ap_rvputs(r, balancer->s->name, "</a></h3>\n\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>"
                 "</tr>\n<tr>", r);
@@ -1242,7 +1238,7 @@ static int balancer_handler(request_rec 
                 char fbuf[50];
                 worker = *workers;
                 ap_rvputs(r, "<tr>\n<td><a href='", r->uri, "?b=",
-                          balancer->name + sizeof(BALANCER_PREFIX) - 1, "&w=",
+                          balancer->s->name + sizeof(BALANCER_PREFIX) - 1, "&w=",
                           ap_escape_uri(r->pool, worker->s->name),
                           "&nonce=", balancer->s->nonce,
                           "'>", NULL);
@@ -1297,7 +1293,7 @@ static int balancer_handler(request_rec 
             ap_rvputs(r, "</table>\n<input type=hidden name='w' id='w' ",  NULL);
             ap_rvputs(r, "value='", ap_escape_uri(r->pool, wsel->s->name), "'>\n",
NULL);
             ap_rvputs(r, "<input type=hidden name='b' id='b' ", NULL);
-            ap_rvputs(r, "value='", bsel->name + sizeof(BALANCER_PREFIX) - 1,
+            ap_rvputs(r, "value='", bsel->s->name + sizeof(BALANCER_PREFIX) - 1,
                       "'>\n", NULL);
             ap_rvputs(r, "<input type=hidden name='nonce' id='nonce' value='",
                       bsel->s->nonce, "'>\n", NULL);
@@ -1308,7 +1304,7 @@ static int balancer_handler(request_rec 
             const ap_list_provider_names_t *pname;
             int i;
             ap_rputs("<h3>Edit balancer settings for ", r);
-            ap_rvputs(r, bsel->name, "</h3>\n", NULL);
+            ap_rvputs(r, bsel->s->name, "</h3>\n", NULL);
             ap_rputs("<form method='POST' enctype='application/x-www-form-urlencoded'
action='", r);
             ap_rvputs(r, action, "'>\n", NULL);
             ap_rputs("<dl>\n<table>\n", r);
@@ -1347,7 +1343,7 @@ static int balancer_handler(request_rec 
             }
             ap_rputs("<tr><td colspan=2><input type=submit value='Submit'></td></tr>\n",
r);
             ap_rvputs(r, "</table>\n<input type=hidden name='b' id='b' ", NULL);
-            ap_rvputs(r, "value='", bsel->name + sizeof(BALANCER_PREFIX) - 1,
+            ap_rvputs(r, "value='", bsel->s->name + sizeof(BALANCER_PREFIX) - 1,
                       "'>\n", NULL);
             ap_rvputs(r, "<input type=hidden name='nonce' id='nonce' value='",
                       bsel->s->nonce, "'>\n", NULL);
@@ -1387,7 +1383,7 @@ static void balancer_child_init(apr_pool
             if (rv != APR_SUCCESS) {
                 ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
                              "Failed to init balancer %s in child",
-                             balancer->name);
+                             balancer->s->name);
                 exit(1); /* Ugly, but what else? */
             }
             init_balancer_members(conf->pool, s, balancer);

Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=1206286&r1=1206285&r2=1206286&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Fri Nov 25 19:28:14 2011
@@ -1296,7 +1296,7 @@ PROXY_DECLARE(proxy_balancer *) ap_proxy
     }
     balancer = (proxy_balancer *)conf->balancers->elts;
     for (i = 0; i < conf->balancers->nelts; i++) {
-        if (strcasecmp(balancer->name, uri) == 0) {
+        if (strcasecmp(balancer->s->name, uri) == 0) {
             return balancer;
         }
         balancer++;
@@ -1308,6 +1308,7 @@ PROXY_DECLARE(char *) ap_proxy_define_ba
                                                proxy_balancer **balancer,
                                                proxy_server_conf *conf,
                                                const char *url,
+                                               const char *alias,
                                                int do_malloc)
 {
     char nonce[APR_UUID_FORMATTED_LENGTH + 1];
@@ -1315,6 +1316,7 @@ PROXY_DECLARE(char *) ap_proxy_define_ba
     apr_uuid_t uuid;
     proxy_balancer_shared *bshared;
     char *c, *q, *uri = apr_pstrdup(p, url);
+    const char *sname;
 
     /* We should never get here without a valid BALANCER_PREFIX... */
 
@@ -1338,7 +1340,6 @@ PROXY_DECLARE(char *) ap_proxy_define_ba
         return "Can't find 'byrequests' lb method";
     }
 
-    (*balancer)->name = uri;
     (*balancer)->workers = apr_array_make(p, 5, sizeof(proxy_worker *));
     (*balancer)->gmutex = NULL;
     (*balancer)->tmutex = NULL;
@@ -1353,6 +1354,14 @@ PROXY_DECLARE(char *) ap_proxy_define_ba
 
     bshared->was_malloced = (do_malloc != 0);
     PROXY_STRNCPY(bshared->lbpname, "byrequests");
+    PROXY_STRNCPY(bshared->name, uri);
+    ap_pstr2_alnum(p, bshared->name + sizeof(BALANCER_PREFIX) - 1,
+                   &sname);
+    sname = apr_pstrcat(p, conf->id, "_", sname, NULL);
+    PROXY_STRNCPY(bshared->sname, sname);
+    PROXY_STRNCPY(bshared->alias, alias);
+    bshared->hash = ap_proxy_hashfunc(bshared->name, PROXY_HASHFUNC_DEFAULT);    
+    (*balancer)->hash = bshared->hash;
 
     /* Retrieve a UUID and store the nonce for the lifetime of
      * the process. */
@@ -1397,7 +1406,7 @@ PROXY_DECLARE(apr_status_t) ap_proxy_ini
 
     if (!storage) {
         ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s,
-                     "no provider for %s", balancer->name);
+                     "no provider for %s", balancer->s->name);
         return APR_EGENERAL;
     }
     /*
@@ -1406,7 +1415,7 @@ PROXY_DECLARE(apr_status_t) ap_proxy_ini
      */
     if (!balancer->gmutex) {
         ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s,
-                     "no mutex %s", balancer->name);
+                     "no mutex %s", balancer->s->name);
         return APR_EGENERAL;
     }
 
@@ -1417,12 +1426,12 @@ PROXY_DECLARE(apr_status_t) ap_proxy_ini
     if (rv != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
                      "Failed to reopen mutex %s in child",
-                     balancer->name);
+                     balancer->s->name);
         return rv;
     }
 
     /* now attach */
-    storage->attach(&(balancer->wslot), balancer->sname, &size, &num,
p);
+    storage->attach(&(balancer->wslot), balancer->s->sname, &size, &num,
p);
     if (!balancer->wslot) {
         ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s, "slotmem_attach failed");
         return APR_EGENERAL;



Mime
View raw message