From: Jim Jagielski Date: Tue, 2 Feb 2016 20:28:13 +0000 (+0000) Subject: Now honor changed params! X-Git-Tag: 2.5.0-alpha~2218 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ddc56a597b95aad7968d6651c428194fe07d8163;p=thirdparty%2Fapache%2Fhttpd.git Now honor changed params! git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1728203 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index f1d617e4613..3f4ee651cbb 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -562,9 +562,10 @@ struct proxy_balancer_method { #define PROXY_DECLARE_DATA __declspec(dllimport) #endif -/* Following 3 from health check */ +/* Following 4 from health check */ APR_DECLARE_OPTIONAL_FN(void, hc_show_exprs, (request_rec *)); APR_DECLARE_OPTIONAL_FN(void, hc_select_exprs, (request_rec *, const char *)); +APR_DECLARE_OPTIONAL_FN(int, hc_valid_expr, (request_rec *, const char *)); APR_DECLARE_OPTIONAL_FN(const char *, set_worker_hc_param, (apr_pool_t *, server_rec *, proxy_worker *, const char *, const char *, void *)); diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index 896468f628e..49b21a86346 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -35,6 +35,7 @@ static int (*ap_proxy_retry_worker_fn)(const char *proxy_function, static APR_OPTIONAL_FN_TYPE(hc_show_exprs) *hc_show_exprs_f = NULL; static APR_OPTIONAL_FN_TYPE(hc_select_exprs) *hc_select_exprs_f = NULL; +static APR_OPTIONAL_FN_TYPE(hc_valid_expr) *hc_valid_expr_f = NULL; /* @@ -55,6 +56,7 @@ static int balancer_pre_config(apr_pool_t *pconf, apr_pool_t *plog, set_worker_hc_param_f = APR_RETRIEVE_OPTIONAL_FN(set_worker_hc_param); hc_show_exprs_f = APR_RETRIEVE_OPTIONAL_FN(hc_show_exprs); hc_select_exprs_f = APR_RETRIEVE_OPTIONAL_FN(hc_select_exprs); + hc_valid_expr_f = APR_RETRIEVE_OPTIONAL_FN(hc_valid_expr); return OK; } @@ -1131,6 +1133,44 @@ static int balancer_handler(request_rec *r) wsel->s->lbset = ival; } } + if ((val = apr_table_get(params, "w_hi"))) { + int ival = atoi(val); + if (ival >= HCHECK_WATHCHDOG_INTERVAL) { + wsel->s->interval = apr_time_from_sec(ival); + } + } + if ((val = apr_table_get(params, "w_hp"))) { + int ival = atoi(val); + if (ival >= 1) { + wsel->s->passes = ival; + } + } + if ((val = apr_table_get(params, "w_hf"))) { + int ival = atoi(val); + if (ival >= 1) { + wsel->s->fails = ival; + } + } + if ((val = apr_table_get(params, "w_hm"))) { + proxy_hcmethods_t *method = proxy_hcmethods; + for (; method->name; method++) { + if (!ap_casecmpstr(method->name, val) && method->implemented) + wsel->s->method = method->method; + } + } + if ((val = apr_table_get(params, "w_hu"))) { + if (strlen(val) && strlen(val) < sizeof(wsel->s->hcuri)) + strcpy(wsel->s->hcuri, val); + else + *wsel->s->hcuri = '\0'; + } + if (hc_valid_expr_f && (val = apr_table_get(params, "w_he"))) { + if (strlen(val) && hc_valid_expr_f(r, val) && strlen(val) < sizeof(wsel->s->hcexpr)) + strcpy(wsel->s->hcexpr, val); + else + *wsel->s->hcexpr = '\0'; + } + /* if enabling, we need to reset all lb params */ if (bsel && !was_usable && PROXY_WORKER_IS_USABLE(wsel)) { bsel->s->need_reset = 1; diff --git a/modules/proxy/mod_proxy_hcheck.c b/modules/proxy/mod_proxy_hcheck.c index cdceddfc816..d861687e18f 100644 --- a/modules/proxy/mod_proxy_hcheck.c +++ b/modules/proxy/mod_proxy_hcheck.c @@ -1047,11 +1047,33 @@ static void hc_select_exprs(request_rec *r, const char *expr) } ap_rprintf(r, "\n", ap_escape_html(r->pool, elts[i].key), - (!ap_casecmpstr(elts[i].key, expr)) ? "selected" : "", + (!strcmp(elts[i].key, expr)) ? "selected" : "", ap_escape_html(r->pool, elts[i].key)); } } +static int hc_valid_expr(request_rec *r, const char *expr) +{ + const apr_table_entry_t *elts; + const apr_array_header_t *hdr; + int i; + sctx_t *ctx = (sctx_t *) ap_get_module_config(r->server->module_config, + &proxy_hcheck_module); + if (apr_is_empty_table(ctx->conditions)) + return 0; + + hdr = apr_table_elts(ctx->conditions); + elts = (const apr_table_entry_t *) hdr->elts; + for (i = 0; i < hdr->nelts; ++i) { + if (!elts[i].key) { + continue; + } + if (!strcmp(elts[i].key, expr)) + return 1; + } + return 0; +} + static const char *hc_get_body(request_rec *r) { apr_off_t length; @@ -1140,6 +1162,7 @@ static void hc_register_hooks(apr_pool_t *p) APR_REGISTER_OPTIONAL_FN(set_worker_hc_param); APR_REGISTER_OPTIONAL_FN(hc_show_exprs); APR_REGISTER_OPTIONAL_FN(hc_select_exprs); + APR_REGISTER_OPTIONAL_FN(hc_valid_expr); ap_hook_post_config(hc_post_config, aszPre, aszSucc, APR_HOOK_LAST); ap_hook_expr_lookup(hc_expr_lookup, NULL, NULL, APR_HOOK_MIDDLE); }