]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sconn: Set SE_FL_ERROR only when there is no more data to read
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 17 Oct 2022 08:21:19 +0000 (10:21 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 17 Nov 2022 13:33:15 +0000 (14:33 +0100)
SE_FL_ERR_PENDING flag is used when there is still data to be read. So we
must take care to not set SE_FL_ERROR too early. Thus, on sending path, it
must be set if SE_FL_EOS was already set.

src/stconn.c

index a6ed548e19928b17125af4aa50752363a5b13eed..44f591cc1ef81ac652b685ba9be85f320f0038d1 100644 (file)
@@ -792,7 +792,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)
+               if (sc->state >= SC_ST_CON && sc_ep_test(sc, SE_FL_EOS))
                        sc_ep_set(sc, SE_FL_ERROR);
                goto out_wakeup;
        }
@@ -1650,7 +1650,8 @@ static int sc_conn_send(struct stconn *sc)
                 */
                if (sc->state < SC_ST_CON)
                        return 0;
-               sc_ep_set(sc, SE_FL_ERROR);
+               if (sc_ep_test(sc, SE_FL_EOS))
+                   sc_ep_set(sc, SE_FL_ERROR);
                return 1;
        }
 
@@ -1764,7 +1765,8 @@ static int sc_conn_send(struct stconn *sc)
        }
 
        if (sc_ep_test(sc, SE_FL_ERROR | SE_FL_ERR_PENDING)) {
-               sc_ep_set(sc, SE_FL_ERROR);
+               if (sc_ep_test(sc, SE_FL_EOS))
+                   sc_ep_set(sc, SE_FL_ERROR);
                return 1;
        }