BUG/MINOR: tcpcheck: Don't forget to reset tcp-check flags on new kind of check

When a new kind of check is found during the parsing of a proxy section (via
an option directive), we must reset tcpcheck flags for this proxy. It is
mandatory to not inherit some flags from a previously declared check (for
instance in the default section).

This patch must be backported as far as 2.2.

(cherry picked from commit 1faf18ae3976cddfb17afa95ea447205330c821e)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
diff --git a/src/check.c b/src/check.c
index 63869b9..9836d36 100644
--- a/src/check.c
+++ b/src/check.c
@@ -1598,8 +1598,8 @@
   ruleset_found:
 	free_tcpcheck_vars(&rules->preset_vars);
 	rules->list = &rs->rules;
+	rules->flags &= ~(TCPCHK_RULES_PROTO_CHK|TCPCHK_RULES_UNUSED_RS);
 	rules->flags |= TCPCHK_RULES_TCP_CHK;
-	rules->flags &= ~TCPCHK_RULES_UNUSED_TCP_RS;
 
   out:
 	return err_code;
@@ -1669,6 +1669,7 @@
 
   ruleset_found:
 	rules->list = &rs->rules;
+	rules->flags &= ~(TCPCHK_RULES_PROTO_CHK|TCPCHK_RULES_UNUSED_RS);
 	rules->flags |= TCPCHK_RULES_REDIS_CHK;
 
   out:
@@ -1768,6 +1769,7 @@
 
   ruleset_found:
 	rules->list = &rs->rules;
+	rules->flags &= ~(TCPCHK_RULES_PROTO_CHK|TCPCHK_RULES_UNUSED_RS);
 	rules->flags |= TCPCHK_RULES_SSL3_CHK;
 
   out:
@@ -1905,6 +1907,7 @@
 
   ruleset_found:
 	rules->list = &rs->rules;
+	rules->flags &= ~(TCPCHK_RULES_PROTO_CHK|TCPCHK_RULES_UNUSED_RS);
 	rules->flags |= TCPCHK_RULES_SMTP_CHK;
 
   out:
@@ -2050,6 +2053,7 @@
 
   ruleset_found:
 	rules->list = &rs->rules;
+	rules->flags &= ~(TCPCHK_RULES_PROTO_CHK|TCPCHK_RULES_UNUSED_RS);
 	rules->flags |= TCPCHK_RULES_PGSQL_CHK;
 
   out:
@@ -2273,6 +2277,7 @@
 
   ruleset_found:
 	rules->list = &rs->rules;
+	rules->flags &= ~(TCPCHK_RULES_PROTO_CHK|TCPCHK_RULES_UNUSED_RS);
 	rules->flags |= TCPCHK_RULES_MYSQL_CHK;
 
   out:
@@ -2356,6 +2361,7 @@
 
   ruleset_found:
 	rules->list = &rs->rules;
+	rules->flags &= ~(TCPCHK_RULES_PROTO_CHK|TCPCHK_RULES_UNUSED_RS);
 	rules->flags |= TCPCHK_RULES_LDAP_CHK;
 
   out:
@@ -2431,6 +2437,7 @@
 
   ruleset_found:
 	rules->list = &rs->rules;
+	rules->flags &= ~(TCPCHK_RULES_PROTO_CHK|TCPCHK_RULES_UNUSED_RS);
 	rules->flags |= TCPCHK_RULES_SPOP_CHK;
 
   out:
@@ -2621,8 +2628,8 @@
 	}
 
 	rules->list = &rs->rules;
+	rules->flags &= ~(TCPCHK_RULES_PROTO_CHK|TCPCHK_RULES_UNUSED_RS);
 	rules->flags |= TCPCHK_RULES_HTTP_CHK;
-	rules->flags &= ~TCPCHK_RULES_UNUSED_HTTP_RS;
 	if (!tcpcheck_add_http_rule(chk, rules, &errmsg)) {
 		ha_alert("parsing [%s:%d] : '%s %s' : %s.\n", file, line, args[0], args[1], errmsg);
 		rules->list = NULL;
@@ -2752,6 +2759,7 @@
 
   ruleset_found:
 	rules->list = &rs->rules;
+	rules->flags &= ~(TCPCHK_RULES_PROTO_CHK|TCPCHK_RULES_UNUSED_RS);
 	rules->flags |= TCPCHK_RULES_AGENT_CHK;
 	srv->do_agent = 1;