]> granicus.if.org Git - apache/commitdiff
Now honor changed params!
authorJim Jagielski <jim@apache.org>
Tue, 2 Feb 2016 20:28:13 +0000 (20:28 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 2 Feb 2016 20:28:13 +0000 (20:28 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1728203 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_balancer.c
modules/proxy/mod_proxy_hcheck.c

index f1d617e46130b153b29c741fbc0b44c5647ce321..3f4ee651cbb5119c8d8e2c9407f806bc056c35d3 100644 (file)
@@ -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 *));
index 896468f628e4f875610b7ac9dbc7597ccfc7dd60..49b21a863469069627b7d30cd6ebfc3b3f3ae966 100644 (file)
@@ -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;
index cdceddfc816c4e7c6267b99fe0fe802266a6e21d..d861687e18fd5f93a6b84f6a0ff5d2e77f783e97 100644 (file)
@@ -1047,11 +1047,33 @@ static void hc_select_exprs(request_rec *r, const char *expr)
         }
         ap_rprintf(r, "<option value='%s' %s >%s</option>\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);
 }