]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: backend: do not try to install a mux when the connection failed
authorWilly Tarreau <w@1wt.eu>
Thu, 18 Jul 2019 14:18:20 +0000 (16:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 18 Jul 2019 14:49:11 +0000 (16:49 +0200)
If si_connect() failed, do not try to install the mux nor to complete
the operations or add the connection to an idle list, and abort quickly
instead. No obvious side effects were identified, but continuing to
allocate some resources after something has already failed seems risky.

This was a result of a prior fix which already wanted to push this code
further : aa089d80b ("BUG/MEDIUM: server: Defer the mux init until after
xprt has been initialized.") but it ought to have pushed it even further
to maintain the error check just after si_connect().

To be backported to 2.0 and 1.9.

src/backend.c

index 05fefcdf37af6c219e51ef270fcca61772702a4f..7cfc2f22a691ed2e06e6a91dbc462239ff61f72c 100644 (file)
@@ -1573,6 +1573,9 @@ int connect_server(struct stream *s)
        }
 
        err = si_connect(&s->si[1], srv_conn);
+       if (err != SF_ERR_NONE)
+               return err;
+
        /* We have to defer the mux initialization until after si_connect()
         * has been called, as we need the xprt to have been properly
         * initialized, or any attempt to recv during the mux init may
@@ -1619,9 +1622,6 @@ int connect_server(struct stream *s)
                srv_conn->flags &= ~(CO_FL_SSL_WAIT_HS | CO_FL_WAIT_L6_CONN);
 #endif
 
-       if (err != SF_ERR_NONE)
-               return err;
-
        /* set connect timeout */
        s->si[1].exp = tick_add_ifset(now_ms, s->be->timeout.connect);