From: Willy Tarreau Date: Thu, 18 Jul 2019 16:40:06 +0000 (+0200) Subject: MEDIUM: backend: always release any existing prior connection in connect_server() X-Git-Tag: v2.1-dev2~292 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a5797aab11e8b49567251fa4a31caf44214a1566;p=thirdparty%2Fhaproxy.git MEDIUM: backend: always release any existing prior connection in connect_server() When entering connect_server() we're not supposed to have a connection already, except when retrying a failed connection, which is pretty rare. Let's simplify the code by starting to unconditionally release any existing connection. For now we don't go further, as this change alone will lead to quite some simplification that'd rather be done as a separate cleanup. --- diff --git a/src/backend.c b/src/backend.c index 1002425a28..fef6399b7e 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1151,11 +1151,11 @@ int connect_server(struct stream *s) int err; - /* Some, such as http_proxy and the LUA, create their connection and - * conn_stream manually, so if we already have a conn_stream, try - * to use it. + /* This will catch some corner cases such as lying connections resulting from + * retries or connect timeouts but will rarely trigger. */ - srv_cs = objt_cs(s->si[1].end); + si_release_endpoint(&s->si[1]); + if (!srv_cs) srv_conn = objt_conn(s->si[1].end); else