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.
This commit is contained in:
Christopher Faulet 2019-01-08 10:43:36 +01:00
parent 0656d9ca75
commit f3eb2b1c24

View 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);
}
}