]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Copy the workers to the comarea for the checker in the post-config.
authorJean-Frederic Clere <jfclere@apache.org>
Sat, 29 Jul 2006 21:08:00 +0000 (21:08 +0000)
committerJean-Frederic Clere <jfclere@apache.org>
Sat, 29 Jul 2006 21:08:00 +0000 (21:08 +0000)
(Instead doing it when parsing the configuration file).

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/httpd-proxy-scoreboard@426837 13f79535-47bb-0310-9956-ffa450edef68

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

index 70d6b77773829da165746fe2568e4b58cf7f8e3c..5a562c5623c404cf109482976a7c72c106dfbd31 100644 (file)
@@ -1151,13 +1151,11 @@ static const char *
         }
     }
     else {
-        int adding = 0;
         proxy_worker *worker = ap_proxy_get_worker(cmd->temp_pool, conf, r);
         if (!worker) {
             const char *err = ap_proxy_add_worker(&worker, cmd->pool, conf, r);
             if (err)
                 return apr_pstrcat(cmd->temp_pool, "ProxyPass ", err, NULL);
-            adding = 1;
         } else {
             ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server,
                          "worker %s already used by another worker", worker->name);
@@ -1170,10 +1168,6 @@ static const char *
             if (err)
                 return apr_pstrcat(cmd->temp_pool, "ProxyPass ", err, NULL);
         }
-       
-        /* XXX: ProxyPass is not a good name look for Location? */
-        if (adding)
-            proxy_checkstorage_add_entry(worker, "ProxyPass");
     }
     return NULL;
 }
@@ -1523,7 +1517,6 @@ static const char *add_member(cmd_parms *cmd, void *dummy, const char *arg)
     const apr_array_header_t *arr;
     const apr_table_entry_t *elts;
     int i; 
-    int adding = 0; 
 
     if (cmd->path)
         path = apr_pstrdup(cmd->pool, cmd->path);
@@ -1559,7 +1552,6 @@ static const char *add_member(cmd_parms *cmd, void *dummy, const char *arg)
         const char *err;
         if ((err = ap_proxy_add_worker(&worker, cmd->pool, conf, name)) != NULL)
             return apr_pstrcat(cmd->temp_pool, "BalancerMember ", err, NULL);
-        adding = 1;
     } else {
             ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server,
                          "worker %s already used by another worker", worker->name);
@@ -1585,9 +1577,6 @@ static const char *add_member(cmd_parms *cmd, void *dummy, const char *arg)
     }
     /* Add the worker to the load balancer */
     ap_proxy_add_worker_to_balancer(cmd->pool, balancer, worker);
-    /* XXX: Holy cow: The worker can belong to more that one balancer! */
-    if (adding)
-        proxy_checkstorage_add_entry(worker, balancer->name);
     return NULL;
 }
 
@@ -1869,6 +1858,9 @@ static int proxy_post_config(apr_pool_t *pconf, apr_pool_t *plog,
     /* if we have a memory provider create the comarea here */
     proxy_create_comarea(pconf);
 
+    /* Also fill the comarea of the health-checker */
+    proxy_checkstorage_add_workers(pconf, s);
+
     return OK;
 }
 
index dcbec49ab4825e948b357fe371201b4a1cfabf0d..9c9cbc1deb0ef71fd83bb4d4312b695cb2286014 100644 (file)
@@ -446,8 +446,8 @@ APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, request_status,
 
 /* proxy_util.c */
 
-PROXY_DECLARE(void) proxy_checkstorage_add_entry(proxy_worker *worker, const char *balancer_name);
 PROXY_DECLARE(void) proxy_create_comarea(apr_pool_t *pconf);
+PROXY_DECLARE(void) proxy_checkstorage_add_workers(apr_pool_t *pconf, server_rec *s);
 PROXY_DECLARE(void) proxy_lookup_storage_provider();
 
 PROXY_DECLARE(request_rec *)ap_proxy_make_fake_req(conn_rec *c, request_rec *r);
index 70a97c7f06608b5ed909a65127bfa230d6137cfb..01f4b6f37ff5cb833bcfd1fd6dfac301b8c840d8 100644 (file)
@@ -2250,10 +2250,47 @@ PROXY_DECLARE(void) proxy_lookup_storage_provider()
     checkstorage = ap_lookup_provider(PROXY_CKMETHOD, "default", "0");
 }
 
-/* Store the worker information in the comarea */
-PROXY_DECLARE(void) proxy_checkstorage_add_entry(proxy_worker *worker, const char *balancer_name)
+/* Copy all the worker information in the comarea */
+PROXY_DECLARE(void) proxy_checkstorage_add_workers(apr_pool_t *pconf, server_rec *s)
 {
     if (checkstorage) {
-        checkstorage->add_entry(worker, balancer_name, worker->id);
+        while (s) {
+            void *sconf = s->module_config;
+            proxy_server_conf *conf;
+            proxy_worker *worker;
+            proxy_balancer *balancer;
+            int i, j, k;
+
+            conf = (proxy_server_conf *)ap_get_module_config(sconf, &proxy_module);
+            worker = (proxy_worker *) conf->workers->elts;
+            for (i = 0; i < conf->workers->nelts; i++) {
+                const char *name = NULL;
+                /* find the balancer if any */
+                balancer = (proxy_balancer *)conf->balancers->elts;
+                for (j = 0; j< conf->balancers->nelts; j++) {
+                    proxy_worker *myworker = (proxy_worker *)balancer->workers->elts;
+                    for (k = 0; k < balancer->workers->nelts; k++) {
+                        if (myworker->id == worker->id) {
+                            name = balancer->name;
+                            break;
+                        }
+                        myworker++;
+                    }
+                    if (name)
+                        break;
+                }
+
+                if (!name) {
+                    /* No balancer */
+                    name = "None";
+                }
+                checkstorage->add_entry(worker, name, worker->id);
+                worker++;
+            }
+
+            /* XXX: Do we need something for reverse and forward */
+
+            s = s->next;
+        }
     }
 }