From a5797aab11e8b49567251fa4a31caf44214a1566 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 18 Jul 2019 18:40:06 +0200 Subject: [PATCH] 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. --- src/backend.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 -- 2.47.3