MINOR: proxy/checks: Move parsing of tcp-check option in checks.c
Parsing of the proxy directive "option tcp-check" have been moved in checks.c.
This commit is contained in:
parent
6c2a743538
commit
430e480510
|
@ -69,6 +69,8 @@ int dup_tcpcheck_vars(struct list *dst, struct list *src);
|
|||
int spoe_prepare_healthcheck_request(char **req, int *len);
|
||||
int spoe_handle_healthcheck_response(char *frame, size_t size, char *err, int errlen);
|
||||
|
||||
int proxy_parse_tcp_check_opt(char **args, int cur_arg, struct proxy *curpx, struct proxy *defpx,
|
||||
const char *file, int line);
|
||||
int proxy_parse_redis_check_opt(char **args, int cur_arg, struct proxy *curpx, struct proxy *defpx,
|
||||
const char *file, int line);
|
||||
int proxy_parse_ssl_hello_chk_opt(char **args, int cur_arg, struct proxy *curpx, struct proxy *defpx,
|
||||
|
|
|
@ -2370,38 +2370,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
|||
goto out;
|
||||
}
|
||||
else if (!strcmp(args[1], "tcp-check")) {
|
||||
struct tcpcheck_rules *rules = &curproxy->tcpcheck_rules;
|
||||
|
||||
/* use raw TCPCHK send/expect to check servers' health */
|
||||
if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[1], NULL))
|
||||
err_code |= ERR_WARN;
|
||||
|
||||
if (rules->flags & TCPCHK_RULES_DEF) {
|
||||
/* Only shared ruleset can be inherited from the default section */
|
||||
rules->flags = 0;
|
||||
rules->list = NULL;
|
||||
}
|
||||
else if (rules->list && (rules->flags & TCPCHK_RULES_SHARED)) {
|
||||
ha_alert("parsing [%s:%d] : A shared tcp-check ruleset alreayd configured.\n", file, linenum);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (curproxy != &defproxy && !rules->list) {
|
||||
rules->list = calloc(1, sizeof(*rules->list));
|
||||
if (!rules->list) {
|
||||
ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
LIST_INIT(rules->list);
|
||||
}
|
||||
|
||||
free(curproxy->check_req);
|
||||
curproxy->check_req = NULL;
|
||||
curproxy->options2 &= ~PR_O2_CHK_ANY;
|
||||
curproxy->options2 |= PR_O2_TCPCHK_CHK;
|
||||
if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code))
|
||||
err_code |= proxy_parse_tcp_check_opt(args, 0, curproxy, &defproxy, file, linenum);
|
||||
if (err_code & ERR_FATAL)
|
||||
goto out;
|
||||
}
|
||||
else if (!strcmp(args[1], "external-check")) {
|
||||
|
|
44
src/checks.c
44
src/checks.c
|
@ -5143,6 +5143,50 @@ static void tcpcheck_ruleset_release(struct tcpcheck_ruleset *rs)
|
|||
free(rs);
|
||||
}
|
||||
|
||||
/* Parses the "option tcp-check" proxy keyword */
|
||||
int proxy_parse_tcp_check_opt(char **args, int cur_arg, struct proxy *curpx, struct proxy *defpx,
|
||||
const char *file, int line)
|
||||
{
|
||||
struct tcpcheck_rules *rules = &curpx->tcpcheck_rules;
|
||||
int err_code = 0;
|
||||
|
||||
if (warnifnotcap(curpx, PR_CAP_BE, file, line, args[cur_arg+1], NULL))
|
||||
err_code |= ERR_WARN;
|
||||
|
||||
if (alertif_too_many_args_idx(0, 1, file, line, args, &err_code))
|
||||
goto out;
|
||||
|
||||
if (rules->flags & TCPCHK_RULES_DEF) {
|
||||
/* Only shared ruleset can be inherited from the default section */
|
||||
rules->flags = 0;
|
||||
rules->list = NULL;
|
||||
}
|
||||
else if (rules->list && (rules->flags & TCPCHK_RULES_SHARED)) {
|
||||
ha_alert("parsing [%s:%d] : A shared tcp-check ruleset alreayd configured.\n", file, line);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (curpx != defpx && !rules->list) {
|
||||
rules->list = calloc(1, sizeof(*rules->list));
|
||||
if (!rules->list) {
|
||||
ha_alert("parsing [%s:%d] : out of memory.\n", file, line);
|
||||
goto error;
|
||||
}
|
||||
LIST_INIT(rules->list);
|
||||
}
|
||||
|
||||
free(curpx->check_req);
|
||||
curpx->check_req = NULL;
|
||||
curpx->options2 &= ~PR_O2_CHK_ANY;
|
||||
curpx->options2 |= PR_O2_TCPCHK_CHK;
|
||||
|
||||
out:
|
||||
return err_code;
|
||||
|
||||
error:
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Parses the "option redis-check" proxy keyword */
|
||||
int proxy_parse_redis_check_opt(char **args, int cur_arg, struct proxy *curpx, struct proxy *defpx,
|
||||
|
|
Loading…
Reference in New Issue