On 01/16/2016 08:07 PM, j...@apache.org wrote:
> Author: jim
> Date: Sat Jan 16 19:07:54 2016
> New Revision: 1725018
> 
> URL: http://svn.apache.org/viewvc?rev=1725018&view=rev
> Log:
> Move to a set of health check workers, mapping to
> each worker itself, instead of a single reused generic
> worker.
> 
> Modified:
>     httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c
> 
> Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c
> URL: 
> http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c?rev=1725018&r1=1725017&r2=1725018&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c (original)
> +++ httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c Sat Jan 16 19:07:54 
> 2016

> @@ -57,43 +57,81 @@ static void *hc_create_config(apr_pool_t
>      apr_pool_create(&ctx->p, p);
>      ctx->templates = apr_array_make(ctx->p, 10, sizeof(hc_template_t));
>      ctx->conditions = apr_array_make(ctx->p, 10, sizeof(hc_condition_t));
> -    ctx->hc = NULL;
> +    ctx->hcworkers = apr_hash_make(ctx->p);
>      ctx->s = s;
>  
>      return ctx;
>  }
>  
> -static void hc_child_init(apr_pool_t *p, server_rec *s)
> +static proxy_worker *hc_get_hcworker(sctx_t *ctx, proxy_worker *worker)
>  {
>      proxy_worker *hc = NULL;
> +    const char* wptr;
>  
> -    /* TODO */
> -    while (s) {
> -        sctx_t *ctx = (sctx_t *) ap_get_module_config(s->module_config,
> -                                                      &proxy_hcheck_module);
> -        if (!hc) {
> -            ap_proxy_define_worker(ctx->p, &hc, NULL, NULL, 
> "http://www.apache.org";, 0);
> -            PROXY_STRNCPY(hc->s->name,     "proxy:hcheck");
> -            PROXY_STRNCPY(hc->s->hostname, "*");
> -            PROXY_STRNCPY(hc->s->scheme,   "*");
> -            hc->hash.def = hc->s->hash.def =
> -                ap_proxy_hashfunc(hc->s->name, PROXY_HASHFUNC_DEFAULT);
> -            hc->hash.fnv = hc->s->hash.fnv =
> -                ap_proxy_hashfunc(hc->s->name, PROXY_HASHFUNC_FNV);
> -            /* Do not disable worker in case of errors */
> -            hc->s->status |= PROXY_WORKER_IGNORE_ERRORS;
> -            /* Mark as the "generic" worker */
> -            hc->s->status |= PROXY_WORKER_GENERIC;
> -            ctx->hc = hc;
> -            ap_proxy_initialize_worker(ctx->hc, s, ctx->p);
> -            /* Enable address cache for generic reverse worker */
> -            hc->s->is_address_reusable = 1;
> +    wptr = apr_psprintf(ctx->p, "%pp", worker);
> +    hc = (proxy_worker *)apr_hash_get(ctx->hcworkers, wptr, 
> APR_HASH_KEY_STRING);
> +    if (!hc) {
> +        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ctx->s, APLOGNO()
> +                     "Creating hc worker %s for %s://%s:%d",
> +                     wptr, worker->s->scheme, worker->s->hostname,
> +                     (int)worker->s->port);
> +
> +        ap_proxy_define_worker(ctx->p, &hc, NULL, NULL, worker->s->name, 0);
> +        PROXY_STRNCPY(hc->s->name,     wptr);
> +        PROXY_STRNCPY(hc->s->hostname, worker->s->hostname);
> +        PROXY_STRNCPY(hc->s->scheme,   worker->s->scheme);
> +        hc->hash.def = hc->s->hash.def = ap_proxy_hashfunc(hc->s->name, 
> PROXY_HASHFUNC_DEFAULT);
> +        hc->hash.fnv = hc->s->hash.fnv = ap_proxy_hashfunc(hc->s->name, 
> PROXY_HASHFUNC_FNV);
> +        hc->s->port = worker->s->port;
> +        /* Do not disable worker in case of errors */
> +        hc->s->status |= PROXY_WORKER_IGNORE_ERRORS;
> +        /* Mark as the "generic" worker */
> +        hc->s->status |= PROXY_WORKER_GENERIC;
> +        ap_proxy_initialize_worker(hc, ctx->s, ctx->p);
> +        /* Enable address cache for generic reverse worker */
> +        hc->s->is_address_reusable = 1;

Hm, shouldn't the HC worker use the same setting as the corresponding worker?
If the workers address is not reusable then worker address might resolve to a 
different IP
each time it resolves which could cause the HC worker to probe the wrong 
backend.

> +        /* tuck away since we need the preparsed address */
> +        hc->cp->addr = worker->cp->addr;
> +        apr_hash_set(ctx->hcworkers, wptr, APR_HASH_KEY_STRING, hc);
> +    }
> +    return hc;
> +}
> +

Regards

RĂ¼diger

Reply via email to