]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stconn: Stop to set SE_FL_ERROR on sending path
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Apr 2023 07:42:59 +0000 (09:42 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Apr 2023 15:05:53 +0000 (17:05 +0200)
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.

src/stconn.c

index eca1e457570623756d9df23795dafb1935c5b5da..f6ca85aff95ac707ac2a2fd68bb56c5b7f951f32 100644 (file)
@@ -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;
        }