]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: stconn: Handle abortonclose if backend connection was already set up
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 13 Nov 2023 18:16:09 +0000 (19:16 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 14 Nov 2023 10:01:51 +0000 (11:01 +0100)
abortonclose option is a backend option, it should not be handle on frontend
side. Of course a frontend can also be a backend but the option should not
be handled too early because it is not necessarily the selected backend
(think about a listen proxy routing requests to another backend).

It is especially an issue when the abortonclose option is enabled in the
defaults section and disabled by the selected backend. Because in this case,
the option may still be enabled while it should not.

Thus, now we wait the backend connection was set up to handle the option. To
do so, we check the backend SC state. The option is ignored if it is in
ST_CS_INI state. For all other states, it means the backend was already
selected.

This patch could be backported as far as 2.2.

src/stconn.c

index d6e4683d431a793ec3f8a8e6695c1971b7794061..46ce76bea7e490b1e62b5618d7adb27130986f61 100644 (file)
@@ -1327,7 +1327,10 @@ static int sc_conn_recv(struct stconn *sc)
        }
 
        /* Instruct the mux it must subscribed for read events */
-       flags |= ((!conn_is_back(conn) && (__sc_strm(sc)->be->options & PR_O_ABRT_CLOSE)) ? CO_RFL_KEEP_RECV : 0);
+       if (!conn_is_back(conn) &&                                 /* for frontend conns only */
+           (sc_opposite(sc)->state != SC_ST_INI) &&               /* before backend connection setup */
+           (__sc_strm(sc)->be->options & PR_O_ABRT_CLOSE))        /* if abortonclose option is set for the current backend */
+               flags |= CO_RFL_KEEP_RECV;
 
        /* Important note : if we're called with POLL_IN|POLL_HUP, it means the read polling
         * was enabled, which implies that the recv buffer was not full. So we have a guarantee