]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: connection: Be sure to always install a mux for sync connect
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 29 Jul 2020 20:42:27 +0000 (22:42 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 30 Jul 2020 07:31:09 +0000 (09:31 +0200)
Sometime, a server connection may be performed synchronously. Most of time on
TCP socket, it does not happen. It is easier to have sync connect with unix
socket. When it happens, if we are not waiting for any hanshake completion, we
must be sure to have a mux installed before leaving the connect_server()
function because an attempt to send may be done before the I/O connection
handler have a chance to be executed to install the mux, if not already done.

For now, It is not expected to perform a send with no mux installed, leading to
a crash if it happens.

This patch should fix the issue #762 and probably #779 too. It must be
backported as far as 1.9.

src/backend.c

index b305ec0c8f91d6a5e4f585587fae42bed39795f3..4d47c943052320a750fb9dcbd9bea19b53de2068 100644 (file)
@@ -1581,6 +1581,14 @@ int connect_server(struct stream *s)
        if ((srv_cs->flags & CS_FL_EOI) && !(si_ic(&s->si[1])->flags & CF_EOI))
                si_ic(&s->si[1])->flags |= (CF_EOI|CF_READ_PARTIAL);
 
+       /* catch all sync connect while the mux is not already installed */
+       if (!srv_conn->mux && !(srv_conn->flags & CO_FL_WAIT_XPRT)) {
+               if (conn_create_mux(srv_conn) < 0) {
+                       conn_full_close(srv_conn);
+                       return SF_ERR_INTERNAL;
+               }
+       }
+
        return SF_ERR_NONE;  /* connection is OK */
 }