]> granicus.if.org Git - apache/commitdiff
Allow compile time changes of field sizes and be more
authorJim Jagielski <jim@apache.org>
Fri, 25 Nov 2011 17:32:03 +0000 (17:32 +0000)
committerJim Jagielski <jim@apache.org>
Fri, 25 Nov 2011 17:32:03 +0000 (17:32 +0000)
"clear" regarding the diff between balancer and worker slots...

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

modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_balancer.c
modules/proxy/proxy_util.c

index a45adf6434db2b863bd3cdd4755027ee6365e08b..b381e42a74f883a1c28222d650936c3df3784edf 100644 (file)
@@ -162,7 +162,7 @@ typedef struct {
     } proxy_status;             /* Status display options */
     apr_sockaddr_t *source_address;
     apr_global_mutex_t  *mutex; /* global lock (needed??) */
-    ap_slotmem_instance_t *slot;  /* balancers shm data - runtime */
+    ap_slotmem_instance_t *bslot;  /* balancers shm data - runtime */
     ap_slotmem_provider_t *storage;
 
     unsigned int req_set:1;
@@ -296,13 +296,25 @@ PROXY_WORKER_DISABLED | PROXY_WORKER_STOPPED | PROXY_WORKER_IN_ERROR )
 #define PROXY_WORKER_DEFAULT_RETRY    60
 
 /* Some max char string sizes, for shm fields */
+#ifndef PROXY_WORKER_MAX_SCHEME_SIZE
 #define PROXY_WORKER_MAX_SCHEME_SIZE    16
+#endif
+#ifndef PROXY_WORKER_MAX_ROUTE_SIZE
 #define PROXY_WORKER_MAX_ROUTE_SIZE     64
+#endif
+#ifndef PROXY_WORKER_MAX_NAME_SIZE
 #define PROXY_WORKER_MAX_NAME_SIZE      96
+#endif
+#ifndef PROXY_WORKER_MAX_HOSTNAME_SIZE
 #define PROXY_WORKER_MAX_HOSTNAME_SIZE  64
+#endif
+#ifndef PROXY_BALANCER_MAX_STICKY_SIZE
 #define PROXY_BALANCER_MAX_STICKY_SIZE  64
+#endif
 
+#ifndef PROXY_MAX_PROVIDER_NAME_SIZE
 #define PROXY_MAX_PROVIDER_NAME_SIZE    16
+#endif
 
 #define PROXY_STRNCPY(dst, src) apr_cpystrn((dst), (src), sizeof(dst))
 
@@ -413,7 +425,7 @@ typedef struct {
 struct proxy_balancer {
     apr_array_header_t *workers;  /* initially configured workers */
     apr_array_header_t *errstatuses;  /* statuses to force members into error */
-    ap_slotmem_instance_t *slot;  /* worker shm data - runtime */
+    ap_slotmem_instance_t *wslot;  /* worker shm data - runtime */
     ap_slotmem_provider_t *storage;
     int growth;                   /* number of post-config workers can added */
     int max_workers;              /* maximum number of allowed workers */
index cb58afae99b0c3cde0eaf64aca2c9d1392761125..b19d8f1864b2ef2c14830c1266800776650e4251 100644 (file)
@@ -735,7 +735,7 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog,
                 ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "balancer slotmem_create failed");
                 return !OK;
             }
-            conf->slot = new;
+            conf->bslot = new;
         }
         conf->storage = storage;
 
@@ -767,12 +767,12 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog,
                                       apr_pool_cleanup_null);
 
             /* setup shm for balancers */
-            if ((rv = storage->grab(conf->slot, &index)) != APR_SUCCESS) {
+            if ((rv = storage->grab(conf->bslot, &index)) != APR_SUCCESS) {
                 ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "balancer slotmem_grab failed");
                 return !OK;
 
             }
-            if ((rv = storage->dptr(conf->slot, index, (void *)&bshm)) != APR_SUCCESS) {
+            if ((rv = storage->dptr(conf->bslot, index, (void *)&bshm)) != APR_SUCCESS) {
                 ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "balancer slotmem_dptr failed");
                 return !OK;
             }
@@ -794,7 +794,7 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog,
                 ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "worker slotmem_create failed");
                 return !OK;
             }
-            balancer->slot = new;
+            balancer->wslot = new;
             balancer->storage = storage;
 
             /* sync all timestamps */
@@ -806,12 +806,12 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog,
                 proxy_worker_shared *shm;
 
                 worker = *workers;
-                if ((rv = storage->grab(balancer->slot, &index)) != APR_SUCCESS) {
+                if ((rv = storage->grab(balancer->wslot, &index)) != APR_SUCCESS) {
                     ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "worker slotmem_grab failed");
                     return !OK;
 
                 }
-                if ((rv = storage->dptr(balancer->slot, index, (void *)&shm)) != APR_SUCCESS) {
+                if ((rv = storage->dptr(balancer->wslot, index, (void *)&shm)) != APR_SUCCESS) {
                     ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "worker slotmem_dptr failed");
                     return !OK;
                 }
@@ -1084,7 +1084,7 @@ static int balancer_handler(request_rec *r)
             char *ret;
             proxy_worker *nworker;
             nworker = ap_proxy_get_worker(conf->pool, bsel, conf, val);
-            if (!nworker && storage->num_free_slots(bsel->slot)) {
+            if (!nworker && storage->num_free_slots(bsel->wslot)) {
                 if ((rv = PROXY_GLOBAL_LOCK(bsel)) != APR_SUCCESS) {
                     ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                                   "%s: Lock failed for adding worker",
@@ -1095,7 +1095,7 @@ static int balancer_handler(request_rec *r)
                     unsigned int index;
                     proxy_worker_shared *shm;
                     PROXY_COPY_CONF_PARAMS(nworker, conf);
-                    if ((rv = storage->grab(bsel->slot, &index)) != APR_SUCCESS) {
+                    if ((rv = storage->grab(bsel->wslot, &index)) != APR_SUCCESS) {
                         ap_log_rerror(APLOG_MARK, APLOG_EMERG, rv, r,
                                       "worker slotmem_grab failed");
                         if ((rv = PROXY_GLOBAL_UNLOCK(bsel)) != APR_SUCCESS) {
@@ -1105,7 +1105,7 @@ static int balancer_handler(request_rec *r)
                         }
                         return HTTP_BAD_REQUEST;
                     }
-                    if ((rv = storage->dptr(bsel->slot, index, (void *)&shm)) != APR_SUCCESS) {
+                    if ((rv = storage->dptr(bsel->wslot, index, (void *)&shm)) != APR_SUCCESS) {
                         ap_log_rerror(APLOG_MARK, APLOG_EMERG, rv, r,
                                       "worker slotmem_dptr failed");
                         if ((rv = PROXY_GLOBAL_UNLOCK(bsel)) != APR_SUCCESS) {
@@ -1209,7 +1209,7 @@ static int balancer_handler(request_rec *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,
-                       balancer->max_workers - (int)storage->num_free_slots(balancer->slot));
+                       balancer->max_workers - (int)storage->num_free_slots(balancer->wslot));
             if (*balancer->s->sticky) {
                 if (strcmp(balancer->s->sticky, balancer->s->sticky_path)) {
                     ap_rvputs(r, "<td align='center'>", balancer->s->sticky, " | ",
@@ -1340,7 +1340,7 @@ static int balancer_handler(request_rec *r)
                 ap_rvputs(r, "value ='", bsel->s->sticky, NULL);
             }
             ap_rputs("'>&nbsp;&nbsp;&nbsp;&nbsp;(Use '-' to delete)</td></tr>\n", r);
-            if (storage->num_free_slots(bsel->slot) != 0) {
+            if (storage->num_free_slots(bsel->wslot) != 0) {
                 ap_rputs("<tr><td>Add New Worker:</td><td><input name='b_nwrkr' id='b_nwrkr' size=32 type=text>"
                          "&nbsp;&nbsp;&nbsp;&nbsp;Are you sure? <input name='b_wyes' id='b_wyes' type=checkbox value='1'>"
                          "</td></tr>", r);
@@ -1373,8 +1373,8 @@ static void balancer_child_init(apr_pool_t *p, server_rec *s)
         if (conf->balancers->nelts) {
             apr_size_t size;
             unsigned int num;
-            storage->attach(&(conf->slot), conf->id, &size, &num, p);
-            if (!conf->slot) {
+            storage->attach(&(conf->bslot), conf->id, &size, &num, p);
+            if (!conf->bslot) {
                 ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, "slotmem_attach failed");
                 exit(1); /* Ugly, but what else? */
             }
index 356671d83155740de2a775c5d928efdb6d12f637..2677e8ce5fdf74ae3f6e7b7fc56945b1dbb0019b 100644 (file)
@@ -1422,8 +1422,8 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_balancer(proxy_balancer *balance
     }
 
     /* now attach */
-    storage->attach(&(balancer->slot), balancer->sname, &size, &num, p);
-    if (!balancer->slot) {
+    storage->attach(&(balancer->wslot), balancer->sname, &size, &num, p);
+    if (!balancer->wslot) {
         ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s, "slotmem_attach failed");
         return APR_EGENERAL;
     }
@@ -2917,7 +2917,7 @@ PROXY_DECLARE(apr_status_t) ap_proxy_sync_balancer(proxy_balancer *b, server_rec
     for (index = 0; index < b->max_workers; index++) {
         int found;
         apr_status_t rv;
-        if ((rv = storage->dptr(b->slot, (unsigned int)index, (void *)&shm)) != APR_SUCCESS) {
+        if ((rv = storage->dptr(b->wslot, (unsigned int)index, (void *)&shm)) != APR_SUCCESS) {
             ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "worker slotmem_dptr failed");
             return APR_EGENERAL;
         }