]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: stconn: Only reset connect expiration when processing backend side
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 20 Jul 2022 11:24:04 +0000 (13:24 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 21 Jul 2022 12:50:14 +0000 (14:50 +0200)
Since commit ae024ced0 ("MEDIUM: stream-int/stream: Use connect expiration
instead of SI expiration"), the connect expiration date is per-stream. So
there is only one expiration date instead of one per side, front and
back. So when a stream-connector is processed, we must test if it is a
frontend or a backend stconn before updating the connect expiration
date. Indeed, the frontend stconn must not reset the connect expiration
date.

This bug may have several side effect. One known bug is about peer sessions
blocked because the frontend peer applet is in ST_CLO state and its backend
connection is in ST_TAR state but without connect expiration date.

This patch should fix the issue #1791 and #1792. It must be backported to
2.6.

src/stconn.c

index d69e68e5ff1ed8fe500d9eda782b22bb91a1d69e..ca36e4958e6bcb772db1617a81604b40149d853e 100644 (file)
@@ -512,7 +512,8 @@ static void sc_app_shutr(struct stconn *sc)
 
        if (sc_oc(sc)->flags & CF_SHUTW) {
                sc->state = SC_ST_DIS;
-               __sc_strm(sc)->conn_exp = TICK_ETERNITY;
+               if (sc->flags & SC_FL_ISBACK)
+                       __sc_strm(sc)->conn_exp = TICK_ETERNITY;
        }
        else if (sc->flags & SC_FL_NOHALF) {
                /* we want to immediately forward this close to the write side */
@@ -572,7 +573,8 @@ static void sc_app_shutw(struct stconn *sc)
                sc->flags &= ~SC_FL_NOLINGER;
                ic->flags |= CF_SHUTR;
                ic->rex = TICK_ETERNITY;
-               __sc_strm(sc)->conn_exp = TICK_ETERNITY;
+               if (sc->flags & SC_FL_ISBACK)
+                       __sc_strm(sc)->conn_exp = TICK_ETERNITY;
        }
 
        /* note that if the task exists, it must unregister itself once it runs */
@@ -654,7 +656,8 @@ static void sc_app_shutr_conn(struct stconn *sc)
        if (sc_oc(sc)->flags & CF_SHUTW) {
                sc_conn_shut(sc);
                sc->state = SC_ST_DIS;
-               __sc_strm(sc)->conn_exp = TICK_ETERNITY;
+               if (sc->flags & SC_FL_ISBACK)
+                       __sc_strm(sc)->conn_exp = TICK_ETERNITY;
        }
        else if (sc->flags & SC_FL_NOHALF) {
                /* we want to immediately forward this close to the write side */
@@ -738,7 +741,8 @@ static void sc_app_shutw_conn(struct stconn *sc)
                sc->flags &= ~SC_FL_NOLINGER;
                ic->flags |= CF_SHUTR;
                ic->rex = TICK_ETERNITY;
-               __sc_strm(sc)->conn_exp = TICK_ETERNITY;
+               if (sc->flags & SC_FL_ISBACK)
+                       __sc_strm(sc)->conn_exp = TICK_ETERNITY;
        }
 }
 
@@ -880,7 +884,8 @@ static void sc_app_shutr_applet(struct stconn *sc)
        if (sc_oc(sc)->flags & CF_SHUTW) {
                appctx_shut(__sc_appctx(sc));
                sc->state = SC_ST_DIS;
-               __sc_strm(sc)->conn_exp = TICK_ETERNITY;
+               if (sc->flags & SC_FL_ISBACK)
+                       __sc_strm(sc)->conn_exp = TICK_ETERNITY;
        }
        else if (sc->flags & SC_FL_NOHALF) {
                /* we want to immediately forward this close to the write side */
@@ -942,7 +947,8 @@ static void sc_app_shutw_applet(struct stconn *sc)
                sc->flags &= ~SC_FL_NOLINGER;
                ic->flags |= CF_SHUTR;
                ic->rex = TICK_ETERNITY;
-               __sc_strm(sc)->conn_exp = TICK_ETERNITY;
+               if (sc->flags & SC_FL_ISBACK)
+                       __sc_strm(sc)->conn_exp = TICK_ETERNITY;
        }
 }
 
@@ -1259,7 +1265,8 @@ static void sc_conn_read0(struct stconn *sc)
        oc->wex = TICK_ETERNITY;
 
        sc->state = SC_ST_DIS;
-       __sc_strm(sc)->conn_exp = TICK_ETERNITY;
+       if (sc->flags & SC_FL_ISBACK)
+               __sc_strm(sc)->conn_exp = TICK_ETERNITY;
        return;
 }
 
@@ -1838,7 +1845,8 @@ static int sc_conn_process(struct stconn *sc)
 
        if (!sc_state_in(sc->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO) &&
            (conn->flags & CO_FL_WAIT_XPRT) == 0) {
-               __sc_strm(sc)->conn_exp = TICK_ETERNITY;
+               if (sc->flags & SC_FL_ISBACK)
+                       __sc_strm(sc)->conn_exp = TICK_ETERNITY;
                oc->flags |= CF_WRITE_NULL;
                if (sc->state == SC_ST_CON)
                        sc->state = SC_ST_RDY;