Skip to content

Commit

Permalink
BUG/MEDIUM: checks: Don't add a tcpcheck ruleset twice in the shared …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
capflam committed May 29, 2020
1 parent 7867525 commit 56192cc
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/checks.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 56192cc

Please sign in to comment.