From: Olivier Houchard Date: Fri, 25 Oct 2019 15:00:54 +0000 (+0200) Subject: BUG/MEDIUM: servers: Only set SF_SRV_REUSED if the connection if fully ready. X-Git-Tag: v2.1-dev4~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e8f5f5d8b228d71333fb60229dc908505baf9222;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: servers: Only set SF_SRV_REUSED if the connection if fully ready. In connect_server(), if we're reusing a connection, only use SF_SRV_REUSED if the connection is fully ready. We may be using a multiplexed connection created by another stream that is not yet ready, and may fail. If we set SF_SRV_REUSED, process_stream() will then not wait for the timeout to expire, and retry to connect immediately. This should be backported to 1.9 and 2.0. This commit depends on 55234e33708c5a584fb9efea81d71ac47235d518. --- diff --git a/src/backend.c b/src/backend.c index e7e0e77232..a7bcfc4a43 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1482,8 +1482,13 @@ int connect_server(struct stream *s) if (srv_conn->mux->reset) srv_conn->mux->reset(srv_conn); } - else - s->flags |= SF_SRV_REUSED; + else { + /* Only consider we're doing reuse if the connection was + * ready. + */ + if (srv_conn->mux->ctl(srv_conn, MUX_STATUS, NULL) & MUX_STATUS_READY) + s->flags |= SF_SRV_REUSED; + } /* flag for logging source ip/port */ if (strm_fe(s)->options2 & PR_O2_SRC_ADDR)