]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Move what belongs to the health_checker in the health checker.
authorJean-Frederic Clere <jfclere@apache.org>
Mon, 31 Jul 2006 15:43:11 +0000 (15:43 +0000)
committerJean-Frederic Clere <jfclere@apache.org>
Mon, 31 Jul 2006 15:43:11 +0000 (15:43 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/httpd-proxy-scoreboard@427145 13f79535-47bb-0310-9956-ffa450edef68

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

index c4ceca37347d1ff99d46de1aee42215e0cbcf301..000108e6f3545b5908aeda757e86f15f3264f294 100644 (file)
@@ -1871,9 +1871,6 @@ 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, s);
 
-    /* Also fill the comarea of the health-checker */
-    proxy_checkstorage_add_workers(pconf, s);
-
     return OK;
 }
 
index 961f263386b5be7c4d036e6eec9d0e5fd45c246a..47ceb1a9a010691770cb592364c5bffa70638959 100644 (file)
@@ -449,7 +449,6 @@ APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, request_status,
 /* proxy_util.c */
 
 PROXY_DECLARE(ap_slotmem_t *) proxy_create_comarea(apr_pool_t *pconf, server_rec *s);
-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 010a27dcdd822a223b8d350f324af828014daff6..5a139a9efddefc51e62e06e0762014b209393aeb 100644 (file)
@@ -18,13 +18,14 @@ static int healthck_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
                               apr_pool_t *ptemp)
 {
     slotmem_storage_method *checkstorage;
-    const health_worker_method *worker_storage = health_checker_get_storage();
+    const health_worker_method *worker_storage;
     ap_slotmem_t *myscore;
     
     checkstorage = ap_lookup_provider(SLOTMEM_STORAGE, "shared", "0");
     if (checkstorage) {
         health_checker_init_slotmem_storage(checkstorage);
     }
+    worker_storage = ap_lookup_provider(PROXY_CKMETHOD, "default", "0");
     if (checkstorage && worker_storage) {
         checkstorage->ap_slotmem_create(&myscore, "proxy/checker", worker_storage->getentrysize(), 128, pconf);
         health_checker_init_slotmem(myscore);
@@ -32,30 +33,64 @@ static int healthck_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
     return OK;
 }
 
-/* XXX: Was to get ap_proxy_lb_workers()
 static int healthck_post_config(apr_pool_t *pconf, apr_pool_t *plog,
                                 apr_pool_t *ptemp, server_rec *s)
 {
-    slotmem_storage_method *checkstorage = health_checker_get_slotmem_storage();
-    health_worker_method *worker_storage = health_checker_get_storage();
-    ap_slotmem_t *myscore;
+    const health_worker_method *worker_storage;
+    worker_storage = ap_lookup_provider(PROXY_CKMETHOD, "default", "0");
+    
+    if (worker_storage) {
+        while (s) {
+            void *sconf = s->module_config;
+            proxy_server_conf *conf;
+            proxy_worker *worker;
+            proxy_balancer *balancer;
+            int i, j, k;
 
-    if (checkstorage && worker_storage) {
-        checkstorage->ap_slotmem_create(&myscore, "proxy/checker", worker_storage->getentrysize(), ap_proxy_lb_workers(), pconf);
-        health_checker_init_slotmem(myscore);
+            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";
+                }
+                worker_storage->add_entry(worker, name, worker->id);
+                worker++;
+            }
+
+            /* XXX: Do we need something for reverse and forward */
+
+            s = s->next;
+        }
     }
     return OK;
-
 }
- */
 
 static void ap_healthstore_register_hook(apr_pool_t *p)
 {
-    static const char * const aszPos[] = { "mod_sharedmem.c", NULL };
+    static const char * const prePos[] = { "mod_sharedmem.c", NULL };
+    static const char * const postPos[] = { "mod_proxy.c", NULL };
 
     const health_worker_method *worker_storage = health_checker_get_storage();
     ap_register_provider(p, PROXY_CKMETHOD, "default", "0", worker_storage);
-    ap_hook_pre_config(healthck_pre_config, NULL, aszPos, APR_HOOK_MIDDLE);
+    ap_hook_pre_config(healthck_pre_config, NULL, prePos, APR_HOOK_MIDDLE);
+    ap_hook_post_config(healthck_post_config, NULL, postPos, APR_HOOK_MIDDLE);
 }
 
 module AP_MODULE_DECLARE_DATA proxy_health_checker_module = {
index e7bec2943842e577eff4649dca933efc2537520c..f7df8b63f756f95d8e2121e3d7f91c2673e143ad 100644 (file)
@@ -43,8 +43,6 @@ APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(proxy, PROXY, int, create_req,
                                    OK, DECLINED)
 /* Storage for the comarea */
 static const slotmem_storage_method *storage = NULL;
-/* Health checker handler */
-static const health_worker_method *checkstorage = NULL;
 
 /* already called in the knowledge that the characters are hex digits */
 PROXY_DECLARE(int) ap_proxy_hex2c(const char *x)
@@ -2247,50 +2245,4 @@ PROXY_DECLARE(void) proxy_lookup_storage_provider()
         storage = ap_lookup_provider(SLOTMEM_STORAGE, "score", "0");
     if (!storage)
         storage = ap_lookup_provider(SLOTMEM_STORAGE, "plain", "0");
-    checkstorage = ap_lookup_provider(PROXY_CKMETHOD, "default", "0");
-}
-
-/* Copy all the worker information in the comarea */
-PROXY_DECLARE(void) proxy_checkstorage_add_workers(apr_pool_t *pconf, server_rec *s)
-{
-    if (checkstorage) {
-        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;
-        }
-    }
 }