BUG/MEDIUM: checks: Don't add a tcpcheck ruleset twice in the shared tree

When a tcpcheck ruleset is created, it is automatically inserted in a global
tree. Unfortunately for applicative health checks (redis, mysql...), the created
ruleset is inserted a second time during the directive parsing. The leads to a
infinite loop when haproxy is stopped when we try to scan the tree to release
all tcpcheck rulesets.

Now, only the function responsible to create the tcpcheck ruleset insert it into
the tree.

No backport needed.
This commit is contained in:
Christopher Faulet 2020-05-29 08:10:50 +02:00
parent 78675252fb
commit 56192cc60b

View File

@ -944,7 +944,9 @@ static struct tcpcheck_ruleset *find_tcpcheck_ruleset(const char *name)
return NULL;
}
/* Creates a new shared tcp-check ruleset */
/* Creates a new shared tcp-check ruleset and insert it in shared_tcpchecks
* tree.
*/
static struct tcpcheck_ruleset *create_tcpcheck_ruleset(const char *name)
{
struct tcpcheck_ruleset *rs;
@ -6276,8 +6278,6 @@ int proxy_parse_redis_check_opt(char **args, int cur_arg, struct proxy *curpx, s
chk->index = 1;
LIST_ADDQ(&rs->rules, &chk->list);
ebis_insert(&shared_tcpchecks, &rs->node);
ruleset_found:
rules->list = &rs->rules;
rules->flags |= TCPCHK_RULES_REDIS_CHK;
@ -6377,8 +6377,6 @@ int proxy_parse_ssl_hello_chk_opt(char **args, int cur_arg, struct proxy *curpx,
chk->index = 1;
LIST_ADDQ(&rs->rules, &chk->list);
ebis_insert(&shared_tcpchecks, &rs->node);
ruleset_found:
rules->list = &rs->rules;
rules->flags |= TCPCHK_RULES_SSL3_CHK;
@ -6515,8 +6513,6 @@ int proxy_parse_smtpchk_opt(char **args, int cur_arg, struct proxy *curpx, struc
chk->index = 4;
LIST_ADDQ(&rs->rules, &chk->list);
ebis_insert(&shared_tcpchecks, &rs->node);
ruleset_found:
rules->list = &rs->rules;
rules->flags |= TCPCHK_RULES_SMTP_CHK;
@ -6662,8 +6658,6 @@ int proxy_parse_pgsql_check_opt(char **args, int cur_arg, struct proxy *curpx, s
chk->index = 3;
LIST_ADDQ(&rs->rules, &chk->list);
ebis_insert(&shared_tcpchecks, &rs->node);
ruleset_found:
rules->list = &rs->rules;
rules->flags |= TCPCHK_RULES_PGSQL_CHK;
@ -6887,8 +6881,6 @@ int proxy_parse_mysql_check_opt(char **args, int cur_arg, struct proxy *curpx, s
LIST_ADDQ(&rs->rules, &chk->list);
}
ebis_insert(&shared_tcpchecks, &rs->node);
ruleset_found:
rules->list = &rs->rules;
rules->flags |= TCPCHK_RULES_MYSQL_CHK;
@ -6972,8 +6964,6 @@ int proxy_parse_ldap_check_opt(char **args, int cur_arg, struct proxy *curpx, st
chk->index = 2;
LIST_ADDQ(&rs->rules, &chk->list);
ebis_insert(&shared_tcpchecks, &rs->node);
ruleset_found:
rules->list = &rs->rules;
rules->flags |= TCPCHK_RULES_LDAP_CHK;
@ -7049,8 +7039,6 @@ int proxy_parse_spop_check_opt(char **args, int cur_arg, struct proxy *curpx, st
chk->index = 1;
LIST_ADDQ(&rs->rules, &chk->list);
ebis_insert(&shared_tcpchecks, &rs->node);
ruleset_found:
rules->list = &rs->rules;
rules->flags |= TCPCHK_RULES_SPOP_CHK;
@ -7398,8 +7386,6 @@ static int srv_parse_agent_check(char **args, int *cur_arg, struct proxy *curpx,
chk->index = 1;
LIST_ADDQ(&rs->rules, &chk->list);
ebis_insert(&shared_tcpchecks, &rs->node);
ruleset_found:
rules->list = &rs->rules;
rules->flags |= TCPCHK_RULES_AGENT_CHK;