]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h1: Handle the flag CS_FL_KILL_CONN during a shutdown read/write
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 8 Apr 2019 08:51:20 +0000 (10:51 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 Apr 2019 20:06:53 +0000 (22:06 +0200)
This flag is used to explicitly kill the connection when the CS is closed. It
may be set by tcp rules. It must be respect by the mux-h1.

This patch must be backported to 1.9.

src/mux_h1.c

index 30bb5f7aeee6f5b4f9e86b30febbc345c8984d80..d6ea268105f4d457d237000f5a09151d4724f835 100644 (file)
@@ -2079,21 +2079,26 @@ static void h1_detach(struct conn_stream *cs)
 static void h1_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
 {
        struct h1s *h1s = cs->ctx;
+       struct h1c *h1c;
 
        if (!h1s)
                return;
+       h1c = h1s->h1c;
 
-       if ((h1s->flags & H1S_F_WANT_KAL) &&
-           !(cs->conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH)))
+       if ((cs->flags & CS_FL_KILL_CONN) || (h1c->conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH)))
+               goto do_shutr;
+
+       if (h1s->flags & H1S_F_WANT_KAL)
                return;
 
+  do_shutr:
        /* NOTE: Be sure to handle abort (cf. h2_shutr) */
        if (cs->flags & CS_FL_SHR)
                return;
        if (conn_xprt_ready(cs->conn) && cs->conn->xprt->shutr)
                cs->conn->xprt->shutr(cs->conn, (mode == CS_SHR_DRAIN));
        if ((cs->conn->flags & (CO_FL_SOCK_RD_SH|CO_FL_SOCK_WR_SH)) == (CO_FL_SOCK_RD_SH|CO_FL_SOCK_WR_SH))
-               h1s->h1c->flags = (h1s->h1c->flags & ~H1C_F_CS_SHUTW_NOW) | H1C_F_CS_SHUTDOWN;
+               h1c->flags = (h1c->flags & ~H1C_F_CS_SHUTW_NOW) | H1C_F_CS_SHUTDOWN;
 }
 
 static void h1_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
@@ -2105,12 +2110,13 @@ static void h1_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
                return;
        h1c = h1s->h1c;
 
-       if ((h1s->flags & H1S_F_WANT_KAL) &&
-           !(h1c->conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH)) &&
+       if ((cs->flags & CS_FL_KILL_CONN) || (h1c->conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH)))
+               goto do_shutw;
 
-           h1s->req.state == H1_MSG_DONE && h1s->res.state == H1_MSG_DONE)
+       if ((h1s->flags & H1S_F_WANT_KAL) && h1s->req.state == H1_MSG_DONE && h1s->res.state == H1_MSG_DONE)
                return;
 
+  do_shutw:
        h1c->flags |= H1C_F_CS_SHUTW_NOW;
        if ((cs->flags & CS_FL_SHW) || b_data(&h1c->obuf))
                return;