From f3eb2b1c24d40ca745293a83a872d4e3f2b212c3 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 8 Jan 2019 10:43:36 +0100 Subject: [PATCH] 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. --- src/mux_h1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mux_h1.c b/src/mux_h1.c index 742572abe..60369da90 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); } }