]> granicus.if.org Git - apache/commitdiff
Move useful and shared balancer stuff to the shm slot...
authorJim Jagielski <jim@apache.org>
Fri, 25 Nov 2011 19:28:14 +0000 (19:28 +0000)
committerJim Jagielski <jim@apache.org>
Fri, 25 Nov 2011 19:28:14 +0000 (19:28 +0000)
Provide hooks for post-config/runtime addition of
balancers.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1206286 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/balancers/mod_lbmethod_bybusyness.c
modules/proxy/balancers/mod_lbmethod_byrequests.c
modules/proxy/balancers/mod_lbmethod_bytraffic.c
modules/proxy/mod_proxy.c
modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_balancer.c
modules/proxy/proxy_util.c

index dec610ed3d604eb6e7e567ff9c16ed9bd1bf45b1..9dd246bd9d05aa672128f1a2b049a6d76afb8790 100644 (file)
@@ -38,7 +38,7 @@ static proxy_worker *find_best_bybusyness(proxy_balancer *balancer,
 
     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 {
index e757bf8291ef8935a35352e0cac1b0522c00679f..9cc3bba71ff1ab7e447567464f7e1e8c72048590 100644 (file)
@@ -82,7 +82,7 @@ static proxy_worker *find_best_byrequests(proxy_balancer *balancer,
 
     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 {
index ba05d764f3a37dedf311aff24c17979cd7e64de1..d91bec0c0deeebf921f40631b1d9e70c56a62880 100644 (file)
@@ -54,7 +54,7 @@ static proxy_worker *find_best_bytraffic(proxy_balancer *balancer,
 
     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 {
index 6ef6bcd5968c9c568772d317a1f8788878481a02..684b196717b2ba60d44e996d9fb68679e143e6e7 100644 (file)
@@ -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 *cmd, void *dummy, const char *arg)
     /* 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 *cmd, void *dummy, const char *arg)
     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_parms *cmd, void *mconfig, const char *arg)
             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 *r, int flags)
     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);
index b381e42a74f883a1c28222d650936c3df3784edf..ba92f6fe27c673d3c7e8191476da4c4e1c54a80e 100644 (file)
@@ -304,9 +304,11 @@ PROXY_WORKER_DISABLED | PROXY_WORKER_STOPPED | PROXY_WORKER_IN_ERROR )
 #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_get_balancer(apr_pool_t *p,
  * @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_balancer(apr_pool_t *p,
                                                proxy_balancer **balancer,
                                                proxy_server_conf *conf,
                                                const char *url,
+                                               const char *alias,
                                                int do_malloc);
 
 /**
index b19d8f1864b2ef2c14830c1266800776650e4251..099b5ddb70bbe83402ec3d8661364dd5cd051f7d 100644 (file)
@@ -115,7 +115,7 @@ static void init_balancer_members(apr_pool_t *p, server_rec *s,
         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(proxy_balancer *balancer,
     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(proxy_balancer *balancer,
     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_balancer *balancer, server_rec *s)
             (*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(proxy_worker **worker,
      */
     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(proxy_worker **worker,
         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(proxy_worker **worker,
     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(proxy_worker **worker,
             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(proxy_worker **worker,
 
     /* 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(proxy_worker **worker,
     }
     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(proxy_worker *worker,
     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(proxy_worker *worker,
                 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(proxy_worker *worker,
 
     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_t *pconf, apr_pool_t *plog,
             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_t *pconf, apr_pool_t *plog,
 
             /* 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 *r)
         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 *r)
                 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 *r)
                         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 *r)
                         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 *r)
                         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 *r)
                         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 *r)
                 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 *r)
         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 *r)
 
             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 *r)
                 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 *r)
             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 *r)
             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 *r)
             }
             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_t *p, server_rec *s)
             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);
index 2677e8ce5fdf74ae3f6e7b7fc56945b1dbb0019b..c27ca572635e7e34e331c83409d0bc1b8823806d 100644 (file)
@@ -1296,7 +1296,7 @@ PROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
     }
     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_balancer(apr_pool_t *p,
                                                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_balancer(apr_pool_t *p,
     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_balancer(apr_pool_t *p,
         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_balancer(apr_pool_t *p,
 
     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_initialize_balancer(proxy_balancer *balance
 
     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_initialize_balancer(proxy_balancer *balance
      */
     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_initialize_balancer(proxy_balancer *balance
     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;