BUG/MINOR: stconn: Handle abortonclose if backend connection was already set up
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.
(cherry picked from commit 9327e7efa73b2be17cf8fbe9ab735181a84839fb)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/stconn.c b/src/stconn.c
index af0300d..5f56118 100644
--- a/src/stconn.c
+++ b/src/stconn.c
@@ -1349,7 +1349,10 @@
}
/* 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