From 6f5579160ac6e3860d610656c44aefbc246d0d8c Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 9 Apr 2020 15:58:50 +0200 Subject: [PATCH] MINOR: proxy/checks: Move parsing of external-check option in checks.c Parsing of the proxy directive "option external-check" have been moved in checks.c. --- include/proto/checks.h | 2 ++ src/cfgparse-listen.c | 8 ++------ src/checks.c | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/proto/checks.h b/include/proto/checks.h index 563e01f4c..7fc849760 100644 --- a/include/proto/checks.h +++ b/include/proto/checks.h @@ -87,6 +87,8 @@ int proxy_parse_spop_check_opt(char **args, int cur_arg, struct proxy *curpx, st const char *file, int line); int proxy_parse_httpchk_opt(char **args, int cur_arg, struct proxy *curpx, struct proxy *defpx, const char *file, int line); +int proxy_parse_external_check_opt(char **args, int cur_arg, struct proxy *curpx, struct proxy *defpx, + const char *file, int line); int set_srv_agent_send(struct server *srv, const char *send); diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index 7b33eb06f..ddc7ba2d3 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -2375,12 +2375,8 @@ stats_error_parsing: goto out; } else if (!strcmp(args[1], "external-check")) { - /* excute an external command to check servers' health */ - free(curproxy->check_req); - curproxy->check_req = NULL; - curproxy->options2 &= ~PR_O2_CHK_ANY; - curproxy->options2 |= PR_O2_EXT_CHK; - if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) + err_code |= proxy_parse_external_check_opt(args, 0, curproxy, &defproxy, file, linenum); + if (err_code & ERR_FATAL) goto out; } else if (!strcmp(args[1], "forwardfor")) { diff --git a/src/checks.c b/src/checks.c index ad72e08af..cfe10f8fa 100644 --- a/src/checks.c +++ b/src/checks.c @@ -6339,6 +6339,22 @@ int proxy_parse_httpchk_opt(char **args, int cur_arg, struct proxy *curpx, struc goto out; } +int proxy_parse_external_check_opt(char **args, int cur_arg, struct proxy *curpx, struct proxy *defpx, + const char *file, int line) +{ + int err_code = 0; + + free(curpx->check_req); + curpx->check_req = NULL; + curpx->options2 &= ~PR_O2_CHK_ANY; + curpx->options2 |= PR_O2_EXT_CHK; + if (alertif_too_many_args_idx(0, 1, file, line, args, &err_code)) + goto out; + + out: + return err_code; +} + /* Parse the "addr" server keyword */ static int srv_parse_addr(char **args, int *cur_arg, struct proxy *curpx, struct server *srv, char **errmsg) -- 2.47.3