From b18e988e0dabbb0c382d2dfb5b8701670a386dde Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 23 Jan 2025 10:31:41 +0100 Subject: [PATCH] BUG/MEDIUM: mux-h1: Properly close H1C if an error is reported before sending data It is possible to have front H1 connections waiting for the client timeout while they should be closed because a conneciton error was reported before sebding an error message to the client. It is not a leak because the connections are closed when the timeout expires but it is a waste of ressources, especially if the client timeout is high. When an early error message must be sent to the client, if an error was already detected, no data are sent and the output buffer is released. At this stage, the H1 connection is in CLOSING state and it must be released. But because of a bug, this is not performed. The client timeout is rearmed and the H1 connection is only closed when it expires. To fix the issue, the condition to close a H1C must also be evaluated when an error is detected before sending data. It is only an issue with idle client connections, because there is no H1 stream in that case and the error message is generated by the mux itself. This patch must be backported as far as 2.8. --- src/mux_h1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mux_h1.c b/src/mux_h1.c index a9363cd44d..f30ea37425 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -3912,7 +3912,7 @@ static int h1_send(struct h1c *h1c) b_reset(&h1c->obuf); if (h1c->flags & H1C_F_EOS) h1c->flags |= H1C_F_ERROR; - return 1; + goto end; } if (!b_data(&h1c->obuf)) -- 2.47.3