]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream-int: only use si_release_endpoint() to release a connection
authorWilly Tarreau <w@1wt.eu>
Sun, 19 Jul 2015 17:14:10 +0000 (19:14 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 19 Jul 2015 17:14:10 +0000 (19:14 +0200)
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

index 0745d85e848ad723fb0a47273d48ed82b51848cb..dac4c0a19cb0b4809a655ebf65e115670d395188 100644 (file)
@@ -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);
        }