From d7c7475ad63a30d5c982f8725984f0d31775c77f Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 19 Jul 2015 19:14:10 +0200 Subject: [PATCH] MINOR: stream-int: only use si_release_endpoint() to release a connection Change si_alloc_conn() to call si_release_endpoint() instead of open-coding the connection releasing code when reuse is disabled. This fuses the code with the one already dealing with applets, makes it shorter and helps centralizing the connection freeing logic at a single place. --- include/proto/stream_interface.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h index 0745d85e8..dac4c0a19 100644 --- a/include/proto/stream_interface.h +++ b/include/proto/stream_interface.h @@ -282,19 +282,14 @@ static inline struct connection *si_alloc_conn(struct stream_interface *si, int { struct connection *conn; - /* If we find a connection, we return it, otherwise it's an applet - * and we start by releasing it. + /* If we find a reusable connection, we return it, otherwise we start + * by releasing what we have (non-reusable conn or applet). */ if (si->end) { conn = objt_conn(si->end); - if (conn) { - if (!reuse) { - conn_force_close(conn); - conn_init(conn); - } + if (conn && reuse) return conn; - } - /* it was an applet then */ + si_release_endpoint(si); }