From: Christopher Faulet Date: Tue, 8 Jan 2019 09:43:36 +0000 (+0100) Subject: BUG/MINOR: mux-h1: Close connection on shutr only when shutw was really done X-Git-Tag: v2.0-dev1~248 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f3eb2b1c24d40ca745293a83a872d4e3f2b212c3;p=thirdparty%2Fhaproxy.git BUG/MINOR: mux-h1: Close connection on shutr only when shutw was really done 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. --- diff --git a/src/mux_h1.c b/src/mux_h1.c index 742572abe5..60369da905 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -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); } }