From 0896ea43fc5ac21182f57dd8eb79db2e41321d63 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 4 May 2026 11:57:12 +0200 Subject: [PATCH] CLEANUP: mux-h2: remove the outdated condition to release h2c on timeout The historical code dealing with timeout was left with a confusing condition that is always true but always requires some analysis. It would check if some streams were left pending before deciding to release the connection. It could indeed be problematic to leave with no timeout and an active connection! As Christopher figured, the situation cannot exist because a first check ensures there's no more h2c via h2c_may_expire(), then a call to h2_wake_some_streams() will call h2s_wake_one_stream() for each of the h2s, and all those with no h2c are purged. Thus on return from h2_wake_some_streams() we're guaranteed to have an empty tree. Let's just remove the condition and clean up the code. --- src/mux_h2.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/mux_h2.c b/src/mux_h2.c index 3272c05ab..00c3fe3c4 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -5469,6 +5469,8 @@ do_leave: h2c->task = NULL; h2c_error(h2c, H2_ERR_NO_ERROR); + + /* here we don't have any h2c left, let's kill all h2c-less streams */ h2_wake_some_streams(h2c, 0); if (br_data(h2c->mbuf)) { @@ -5515,11 +5517,8 @@ do_leave: HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock); } - /* either we can release everything now or it will be done later once - * the last stream closes. - */ - if (eb_is_empty(&h2c->streams_by_id)) - h2_release(h2c); + /* now we're done */ + h2_release(h2c); TRACE_LEAVE(H2_EV_H2C_WAKE); return NULL;