From: Willy Tarreau Date: Thu, 18 Jul 2019 14:18:20 +0000 (+0200) Subject: BUG/MINOR: backend: do not try to install a mux when the connection failed X-Git-Tag: v2.1-dev2~393 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=09e0203ef40d2cd42a45a53c53ebc344a1519e50;p=thirdparty%2Fhaproxy.git BUG/MINOR: backend: do not try to install a mux when the connection failed 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. --- diff --git a/src/backend.c b/src/backend.c index 05fefcdf37..7cfc2f22a6 100644 --- a/src/backend.c +++ b/src/backend.c @@ -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);