]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: backend: always release any existing prior connection in connect_server()
authorWilly Tarreau <w@1wt.eu>
Thu, 18 Jul 2019 16:40:06 +0000 (18:40 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 19 Jul 2019 11:50:09 +0000 (13:50 +0200)
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

index 1002425a28c341f3379ed517a81fb762d11de67a..fef6399b7e2034ba22d8d97ee137e2fd243fe487 100644 (file)
@@ -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