* This serves double duty by not only validating (and creating) * the health-check template, but also ties into set_worker_param() * which does the actual setting of worker params in shm. */
| 103 | * which does the actual setting of worker params in shm. |
| 104 | */ |
| 105 | static const char *set_worker_hc_param(apr_pool_t *p, |
| 106 | server_rec *s, |
| 107 | proxy_worker *worker, |
| 108 | const char *key, |
| 109 | const char *val, |
| 110 | void *v) |
| 111 | { |
| 112 | int ival; |
| 113 | hc_template_t *temp; |
| 114 | sctx_t *ctx = (sctx_t *) ap_get_module_config(s->module_config, |
| 115 | &proxy_hcheck_module); |
| 116 | if (!worker && !v) { |
| 117 | return "Bad call to set_worker_hc_param()"; |
| 118 | } |
| 119 | if (!ctx) { |
| 120 | ctx = hc_create_config(p, s); |
| 121 | ap_set_module_config(s->module_config, &proxy_hcheck_module, ctx); |
| 122 | } |
| 123 | temp = (hc_template_t *)v; |
| 124 | if (!strcasecmp(key, "hctemplate")) { |
| 125 | hc_template_t *template; |
| 126 | template = (hc_template_t *)ctx->templates->elts; |
| 127 | for (ival = 0; ival < ctx->templates->nelts; ival++, template++) { |
| 128 | if (!ap_cstr_casecmp(template->name, val)) { |
| 129 | if (worker) { |
| 130 | worker->s->method = template->method; |
| 131 | worker->s->interval = template->interval; |
| 132 | worker->s->passes = template->passes; |
| 133 | worker->s->fails = template->fails; |
| 134 | PROXY_STRNCPY(worker->s->hcuri, template->hurl); |
| 135 | PROXY_STRNCPY(worker->s->hcexpr, template->hcexpr); |
| 136 | } else { |
| 137 | temp->method = template->method; |
| 138 | temp->interval = template->interval; |
| 139 | temp->passes = template->passes; |
| 140 | temp->fails = template->fails; |
| 141 | temp->hurl = apr_pstrdup(p, template->hurl); |
| 142 | temp->hcexpr = apr_pstrdup(p, template->hcexpr); |
| 143 | } |
| 144 | return NULL; |
| 145 | } |
| 146 | } |
| 147 | return apr_psprintf(p, "Unknown ProxyHCTemplate name: %s", val); |
| 148 | } |
| 149 | else if (!strcasecmp(key, "hcmethod")) { |
| 150 | proxy_hcmethods_t *method = proxy_hcmethods; |
| 151 | for (; method->name; method++) { |
| 152 | if (!ap_cstr_casecmp(val, method->name)) { |
| 153 | if (!method->implemented) { |
| 154 | return apr_psprintf(p, "Health check method %s not (yet) implemented", |
| 155 | val); |
| 156 | } |
| 157 | if (worker) { |
| 158 | worker->s->method = method->method; |
| 159 | } else { |
| 160 | temp->method = method->method; |
| 161 | } |
| 162 | return NULL; |
no test coverage detected