Commit 50670619 authored by Jean-Frederic Clere's avatar Jean-Frederic Clere
Browse files

Move what belongs to the health_checker in the health checker.

parent 84fd2d1d
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -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;
}

+0 −1
Original line number Diff line number Diff line
@@ -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);
+47 −12
Original line number Diff line number Diff line
@@ -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 (checkstorage && worker_storage) {
        checkstorage->ap_slotmem_create(&myscore, "proxy/checker", worker_storage->getentrysize(), ap_proxy_lb_workers(), pconf);
        health_checker_init_slotmem(myscore);
    if (worker_storage) {
        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;
                }
    return OK;

                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 = {
+0 −48
Original line number Diff line number Diff line
@@ -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;
        }
    }
}