]> git.kaiwu.me - haproxy.git/commitdiff
CLEANUP: mux-h2: remove the outdated condition to release h2c on timeout
authorWilly Tarreau <w@1wt.eu>
Mon, 4 May 2026 09:57:12 +0000 (11:57 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 4 May 2026 10:01:57 +0000 (12:01 +0200)
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

index 3272c05abe25efef937c03f548e3a8c731195387..00c3fe3c47e1f011ad500b3a76dfd64383c69790 100644 (file)
@@ -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;