From: Christopher Faulet Date: Wed, 10 Nov 2021 14:12:47 +0000 (+0100) Subject: BUG/MEDIUM: conn-stream: Don't reset CS flags on close X-Git-Tag: v2.3.16~12 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=ab3c075;p=haproxy-2.3.git BUG/MEDIUM: conn-stream: Don't reset CS flags on close cs_close() and cs_drain_and_close() are called to close a conn-stream. cs_shutr() and cs_shutw() are called with the appropriate modes. But the conn-stream is not released at this stage. However the flags are reset. Thus, after a cs_close(), we loose shutdown flags. If cs_close() is performed several times, it is a problem. And indeed, it is possible. On one hand, the stream-interface may close the conn-stream. On the other end, the stream always closes it when it is released. It is a problem for the H1 multiplexer. Because the conn-stream flags are reset, the shutr and shutw are performed twice. For a delayed shutdown, the dirty mode is used instead of the normal one because the last call to h1_shutw() overwrite H1C flags set by the first call. This leads to dirty shutdowns while normal ones are required. At the end, it is possible to truncate the messages. This bug was revealed by the commit a85c522d4 ("BUG/MINOR: mux-h1: Save shutdown mode if the shutdown is delayed"). This patch is related to the issue #1450. It must be backported as far as 2.0. (cherry picked from commit f14d750bf7ef6ce95fcf0de14a423c456ebf82c5) Signed-off-by: Christopher Faulet (cherry picked from commit 68a5fa373ead9552c470e14615001653f94dc7ee) [cf: cs_drain_and_close does not exist on the 2.3]] Signed-off-by: Christopher Faulet --- diff --git a/include/haproxy/connection.h b/include/haproxy/connection.h index aa7a206..d667a96 100644 --- a/include/haproxy/connection.h +++ b/include/haproxy/connection.h @@ -264,7 +264,6 @@ static inline void cs_close(struct conn_stream *cs) { cs_shutw(cs, CS_SHW_SILENT); cs_shutr(cs, CS_SHR_RESET); - cs->flags = CS_FL_NONE; } /* sets CS_FL_ERROR or CS_FL_ERR_PENDING on the cs */