| 480 | } |
| 481 | |
| 482 | static proxy_worker *hc_get_hcworker(sctx_t *ctx, proxy_worker *worker, |
| 483 | apr_pool_t *p) |
| 484 | { |
| 485 | proxy_worker *hc = NULL; |
| 486 | apr_port_t port; |
| 487 | |
| 488 | hc = (proxy_worker *)apr_hash_get(ctx->hcworkers, &worker, sizeof worker); |
| 489 | if (!hc) { |
| 490 | apr_uri_t uri; |
| 491 | apr_status_t rv; |
| 492 | const char *url = worker->s->name_ex; |
| 493 | wctx_t *wctx = apr_pcalloc(ctx->p, sizeof(wctx_t)); |
| 494 | |
| 495 | port = (worker->s->port ? worker->s->port |
| 496 | : ap_proxy_port_of_scheme(worker->s->scheme)); |
| 497 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ctx->s, APLOGNO(03248) |
| 498 | "Creating hc worker %pp for %s://%s:%d", |
| 499 | worker, worker->s->scheme, worker->s->hostname_ex, |
| 500 | (int)port); |
| 501 | |
| 502 | ap_proxy_define_worker(ctx->p, &hc, NULL, NULL, worker->s->name_ex, 0); |
| 503 | apr_snprintf(hc->s->name, sizeof hc->s->name, "%pp", worker); |
| 504 | apr_snprintf(hc->s->name_ex, sizeof hc->s->name_ex, "%pp", worker); |
| 505 | PROXY_STRNCPY(hc->s->hostname, worker->s->hostname); /* for compatibility */ |
| 506 | PROXY_STRNCPY(hc->s->hostname_ex, worker->s->hostname_ex); |
| 507 | PROXY_STRNCPY(hc->s->scheme, worker->s->scheme); |
| 508 | PROXY_STRNCPY(hc->s->hcuri, worker->s->hcuri); |
| 509 | PROXY_STRNCPY(hc->s->hcexpr, worker->s->hcexpr); |
| 510 | hc->hash.def = hc->s->hash.def = ap_proxy_hashfunc(hc->s->name_ex, |
| 511 | PROXY_HASHFUNC_DEFAULT); |
| 512 | hc->hash.fnv = hc->s->hash.fnv = ap_proxy_hashfunc(hc->s->name_ex, |
| 513 | PROXY_HASHFUNC_FNV); |
| 514 | hc->s->port = port; |
| 515 | hc->s->conn_timeout_set = worker->s->conn_timeout_set; |
| 516 | hc->s->conn_timeout = worker->s->conn_timeout; |
| 517 | hc->s->ping_timeout_set = worker->s->ping_timeout_set; |
| 518 | hc->s->ping_timeout = worker->s->ping_timeout; |
| 519 | hc->s->timeout_set = worker->s->timeout_set; |
| 520 | hc->s->timeout = worker->s->timeout; |
| 521 | /* Do not disable worker in case of errors */ |
| 522 | hc->s->status |= PROXY_WORKER_IGNORE_ERRORS; |
| 523 | /* Mark as the "generic" worker */ |
| 524 | hc->s->status |= PROXY_WORKER_GENERIC; |
| 525 | ap_proxy_initialize_worker(hc, ctx->s, ctx->p); |
| 526 | hc->s->is_address_reusable = worker->s->is_address_reusable; |
| 527 | hc->s->disablereuse = worker->s->disablereuse; |
| 528 | hc->s->method = worker->s->method; |
| 529 | rv = apr_uri_parse(p, url, &uri); |
| 530 | if (rv == APR_SUCCESS) { |
| 531 | wctx->path = apr_pstrdup(ctx->p, uri.path); |
| 532 | } |
| 533 | wctx->w = worker; |
| 534 | create_hcheck_req(wctx, hc, ctx->p); |
| 535 | hc->context = wctx; |
| 536 | apr_hash_set(ctx->hcworkers, &worker, sizeof worker, hc); |
| 537 | } |
| 538 | /* This *could* have changed via the Balancer Manager */ |
| 539 | /* TODO */ |
no test coverage detected