]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: backend: don't call si_alloc_conn() when we reuse a valid connection
authorWilly Tarreau <w@1wt.eu>
Tue, 4 Aug 2015 17:45:36 +0000 (19:45 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 5 Aug 2015 19:42:12 +0000 (21:42 +0200)
connect_server() already does most of the check that is done again in
si_alloc_conn(), so let's simply reuse the existing connection instead
of calling the function again. It will also simplify the connection
reuse.

Indeed, for reuse to be set, it also requires srv_conn to be valid. In the
end, the only situation where we have to release the existing connection
and allocate a new one is when reuse == 0.

src/backend.c

index d55434da72ee671cf193c39897472e32f5b49587..a1c700765d490f4296600e36b20d5f2b2f2ff7c4 100644 (file)
@@ -1050,7 +1050,9 @@ int connect_server(struct stream *s)
                }
        }
 
-       srv_conn = si_alloc_conn(&s->si[1], reuse);
+       if (!reuse)
+               srv_conn = si_alloc_conn(&s->si[1], 0);
+
        if (!srv_conn)
                return SF_ERR_RESOURCE;