]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h1: Close connection on shutr only when shutw was really done
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 8 Jan 2019 09:43:36 +0000 (10:43 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 8 Jan 2019 10:31:16 +0000 (11:31 +0100)
In h1_shutr(), to fully close the connection, we must be sure the shutdown write
was already performed on the connection. So we know rely on connection flags
instead of conn_stream flags. If CO_FL_SOCK_WR_SH is already set when h1_shutr()
is called, we can do a full connection close. Otherwise, we just do the shutdown
read.

Without this patch, it is possible to close the connection too early with some
outgoing data in the output buf.

This patch must be backported to 1.9.

src/mux_h1.c

index 742572abe5a0472269d2a28cb3b5e3ac145023fa..60369da905abf575bafc3ff4ee10736bd07e7182 100644 (file)
@@ -2114,8 +2114,8 @@ static void h1_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
                return;
        if (conn_xprt_ready(cs->conn) && cs->conn->xprt->shutr)
                cs->conn->xprt->shutr(cs->conn, (mode == CS_SHR_DRAIN));
-       if (cs->flags & CS_FL_SHW) {
-               h1s->h1c->flags = (h1s->h1c->flags & ~H1C_F_CS_SHUTW_NOW) | H1C_F_CS_SHUTW;
+       if (cs->conn->flags & CO_FL_SOCK_WR_SH) {
+               h1c->flags = (h1c->flags & ~H1C_F_CS_SHUTW_NOW) | H1C_F_CS_SHUTW;
                conn_full_close(cs->conn);
        }
 }