]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: checks: do not exit tcp-checks from the middle of the loop
authorWilly Tarreau <w@1wt.eu>
Wed, 17 Jul 2019 16:48:07 +0000 (18:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 19 Jul 2019 09:03:54 +0000 (11:03 +0200)
There's a comment above tcpcheck_main() clearly stating that no return
statement should be placed in the middle, still we did have one after
installing the mux. It looks mostly harmless though as it will only
fail to mark the server as being in error in case of allocation failure
or config issue.

This fix should be backported to 2.0 and probably 1.9 as well.

src/checks.c

index c2ee60136b581e827d006ca43f5ec40ae2c246ce..353b43b1ad41a02897900bf314aee3489934b810 100644 (file)
@@ -2683,7 +2683,7 @@ static char * tcpcheck_get_step_comment(struct check *check, int stepid)
  * connection, presenting the risk of an fd replacement.
  *
  * Please do NOT place any return statement in this function and only leave
- * via the out_unlock label after setting retcode.
+ * via the out_end_tcpcheck label after setting retcode.
  */
 static int tcpcheck_main(struct check *check)
 {
@@ -2886,8 +2886,12 @@ static int tcpcheck_main(struct check *check)
                        }
 
                        conn_prepare(conn, proto, xprt);
-                       if (conn_install_mux(conn, &mux_pt_ops, cs, proxy, NULL) < 0)
-                               return SF_ERR_RESOURCE;
+
+                       if (conn_install_mux(conn, &mux_pt_ops, cs, proxy, NULL) < 0) {
+                               ret = SF_ERR_RESOURCE;
+                               goto fail_check;
+                       }
+
                        cs_attach(cs, check, &check_conn_cb);
 
                        ret = SF_ERR_INTERNAL;
@@ -2912,6 +2916,7 @@ static int tcpcheck_main(struct check *check)
                         * Note that we try to prevent the network stack from sending the ACK during the
                         * connect() when a pure TCP check is used (without PROXY protocol).
                         */
+               fail_check:
                        switch (ret) {
                        case SF_ERR_NONE:
                                /* we allow up to min(inter, timeout.connect) for a connection