diff --git a/src/backend.c b/src/backend.c index d431920d5..28ec547f7 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1482,6 +1482,16 @@ int connect_server(struct stream *s) } #endif /* USE_OPENSSL */ + /* The CO_FL_SEND_PROXY flag may have been set by the connect method, + * if so, add our handshake pseudo-XPRT now. + */ + if ((srv_conn->flags & CO_FL_HANDSHAKE)) { + if (xprt_add_hs(srv_conn) < 0) { + conn_full_close(srv_conn); + return SF_ERR_INTERNAL; + } + } + /* 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 @@ -1506,16 +1516,6 @@ int connect_server(struct stream *s) session_add_conn(srv_conn->owner, srv_conn, srv_conn->target); } } - /* The CO_FL_SEND_PROXY flag may have been set by the connect method, - * if so, add our handshake pseudo-XPRT now. - */ - if ((srv_conn->flags & CO_FL_HANDSHAKE)) { - if (xprt_add_hs(srv_conn) < 0) { - conn_full_close(srv_conn); - return SF_ERR_INTERNAL; - } - } - #if USE_OPENSSL && (defined(OPENSSL_IS_BORINGSSL) || (HA_OPENSSL_VERSION_NUMBER >= 0x10101000L))