From: Christopher Faulet Date: Fri, 14 Apr 2023 07:42:59 +0000 (+0200) Subject: MINOR: stconn: Stop to set SE_FL_ERROR on sending path X-Git-Tag: v2.8-dev8~144 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=56a2b608b0eac08d153151284ef01164e2f855d1;p=thirdparty%2Fhaproxy.git MINOR: stconn: Stop to set SE_FL_ERROR on sending path It is not the SC responsibility to report errors on the SE descriptor. It is the endpoint responsibility. It must switch SE_FL_ERR_PENDING into SE_FL_ERROR if the end of stream was detected. It can even be considered as a bug if it is not done by he endpoint. So now, on sending path, a BUG_ON() is added to abort if SE_FL_EOS and SE_FL_ERR_PENDING flags are set but not SE_FL_ERROR. It is trully important to handle this case in the endpoint to be able to properly shut the endpoint down. --- diff --git a/src/stconn.c b/src/stconn.c index eca1e45757..f6ca85aff9 100644 --- a/src/stconn.c +++ b/src/stconn.c @@ -798,8 +798,7 @@ static void sc_app_chk_snd_conn(struct stconn *sc) if (sc_ep_test(sc, SE_FL_ERROR | SE_FL_ERR_PENDING) || sc_is_conn_error(sc)) { /* Write error on the file descriptor */ - if (sc->state >= SC_ST_CON && sc_ep_test(sc, SE_FL_EOS)) - sc_ep_set(sc, SE_FL_ERROR); + BUG_ON(sc_ep_test(sc, SE_FL_EOS|SE_FL_ERROR|SE_FL_ERR_PENDING) == (SE_FL_EOS|SE_FL_ERR_PENDING)); goto out_wakeup; } @@ -1554,8 +1553,7 @@ static int sc_conn_send(struct stconn *sc) */ if (sc->state < SC_ST_CON) return 0; - if (sc_ep_test(sc, SE_FL_EOS)) - sc_ep_set(sc, SE_FL_ERROR); + BUG_ON(sc_ep_test(sc, SE_FL_EOS|SE_FL_ERROR|SE_FL_ERR_PENDING) == (SE_FL_EOS|SE_FL_ERR_PENDING)); return 1; } @@ -1670,8 +1668,7 @@ static int sc_conn_send(struct stconn *sc) if (sc_ep_test(sc, SE_FL_ERROR | SE_FL_ERR_PENDING)) { oc->flags |= CF_WRITE_EVENT; - if (sc_ep_test(sc, SE_FL_EOS)) - sc_ep_set(sc, SE_FL_ERROR); + BUG_ON(sc_ep_test(sc, SE_FL_EOS|SE_FL_ERROR|SE_FL_ERR_PENDING) == (SE_FL_EOS|SE_FL_ERR_PENDING)); return 1; }