From a1457296d5688d6604ddc319f172f4d74fe163a4 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Thu, 16 Nov 2023 17:13:41 +0100 Subject: [PATCH] BUG/MINOR: mux_h2: reject passive reverse conn if error on add to idle On passive reverse, H2 mux is responsible to insert the connection in the server idle list. This is done via srv_add_to_idle_list(). However, this function may fail for various reason, such as FD usage limit reached. Handle properly this error case. H2 mux flags the connection on error which will cause its release. Prior to this patch, the connection was only released on server timeout. This bug was found inspecting server curr_used_conns counter. Indeed, on connection reverse, this counter is first incremented. It is decremented just after on srv_add_to_idle_list() if insertion is validated. However, if insertion is rejected, the connection was not released which cause curr_used_conns to remains positive. This has the major downside to break the reusing of idle connection on rhttp causing spurrious 503 errors. No need to backport. --- src/mux_h2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mux_h2.c b/src/mux_h2.c index d70f5c5ba..3883e15f6 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -3295,7 +3295,8 @@ static int h2_conn_reverse(struct h2c *h2c) HA_ATOMIC_OR(&h2c->wait_event.tasklet->state, TASK_F_USR1); xprt_set_idle(conn, conn->xprt, conn->xprt_ctx); - srv_add_to_idle_list(srv, conn, 1); + if (!srv_add_to_idle_list(srv, conn, 1)) + goto err; } else { struct listener *l = __objt_listener(h2c->conn->target);