From: Christopher Faulet Date: Mon, 13 Nov 2023 18:16:09 +0000 (+0100) Subject: BUG/MINOR: stconn: Handle abortonclose if backend connection was already set up X-Git-Tag: v2.9-dev10~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9327e7efa73b2be17cf8fbe9ab735181a84839fb;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/stconn.c b/src/stconn.c index d6e4683d43..46ce76bea7 100644 --- a/src/stconn.c +++ b/src/stconn.c @@ -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