From: Christopher Faulet Date: Mon, 12 Feb 2024 17:30:33 +0000 (+0100) Subject: BUG/MEDIUM: stconn: Don't check pending shutdown to wake an applet up X-Git-Tag: v3.0-dev4~50 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=40d98176ba12367ed323edae34373b5f8deaee64;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: stconn: Don't check pending shutdown to wake an applet up This revert of commit 0b93ff8c87 ("BUG/MEDIUM: stconn: Wake applets on sending path if there is a pending shutdown") and 9e394d34e0 ("BUG/MINOR: stconn: Don't report blocked sends during connection establishment") because it was not the right fixes. We must not wake an applet up when a shutdown is pending because it means output some data are still blocked in the channel buffer. The applet does not necessarily consume these data. In this case, the applet may be woken up infinitly, except if it explicitly reports it wont consume datay yet. This patch must be backported as far as 2.8. For older versions, as far as 2.2, it may be backported. If so, a previous fix must be pushed to prevent an HTTP applet to be stuck. In http_ana.c, in http_end_request() and http_end_reponse(), the call to channel_htx_truncate() on the request channel in case of MSG_ERROR must be replace by a call to channel_htx_erase(). --- diff --git a/include/haproxy/sc_strm.h b/include/haproxy/sc_strm.h index ffe9dbac36..016aab267f 100644 --- a/include/haproxy/sc_strm.h +++ b/include/haproxy/sc_strm.h @@ -357,8 +357,6 @@ static inline int sc_is_send_allowed(const struct stconn *sc) { if (sc->flags & SC_FL_SHUT_DONE) return 0; - if (sc->flags & SC_FL_SHUT_WANTED) - return 1; return !sc_ep_test(sc, SE_FL_WAIT_DATA | SE_FL_WONT_CONSUME); } diff --git a/src/stconn.c b/src/stconn.c index 9951c80f42..8260cb039d 100644 --- a/src/stconn.c +++ b/src/stconn.c @@ -967,10 +967,8 @@ static void sc_app_chk_snd_applet(struct stconn *sc) if (unlikely(sc->state != SC_ST_EST || (sc->flags & SC_FL_SHUT_DONE))) return; - /* we only wake the applet up if it was waiting for some data and is ready to consume it - * or if there is a pending shutdown - */ - if (!sc_ep_test(sc, SE_FL_WAIT_DATA|SE_FL_WONT_CONSUME) && !(sc->flags & SC_FL_SHUT_WANTED)) + /* we only wake the applet up if it was waiting for some data and is ready to consume it */ + if (!sc_ep_test(sc, SE_FL_WAIT_DATA|SE_FL_WONT_CONSUME)) return; if (co_data(oc) || sc_ep_have_ff_data(sc)) {