From: Christopher Faulet Date: Wed, 7 Oct 2026 08:59:17 +0000 (+0200) Subject: BUG/MINOR: mux-h1: fix the open streams counter on stream creation failure X-Git-Tag: v3.5-dev10~152 X-Git-Url: https://git.kaiwu.me/$%7BISSUES%7D/static/gitweb.js?a=commitdiff_plain;h=f0d20d41d9bbb38220c0103c91efcff46e9c1296;p=haproxy.git BUG/MINOR: mux-h1: fix the open streams counter on stream creation failure The "h1_open_streams" stats counter is incremented at the end of h1c_frt_stream_new() and h1c_bck_stream_new(), and decremented in h1s_destroy(). But when the stream connector attachment or the sedesc allocation fails after h1s_new() succeeded, h1s_destroy() is called on the error path and decrements the counter which was not incremented. The gauge then drifts and may become negative. The counter is now incremented in h1s_new() as soon as the H1 stream is allocated, so that it is always balanced by h1s_destroy(). The total streams counter is left where it was so that it only counts successfully created streams. This patch may be backported to all supported versions. --- diff --git a/src/mux_h1.c b/src/mux_h1.c index 9eea1e39f..2c30ae8a6 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -950,6 +950,8 @@ static struct h1s *h1s_new(struct h1c *h1c) } h1s->h1c = h1c; h1c->h1s = h1s; + /* must be done here since decremented by h1s_destroy() */ + HA_ATOMIC_INC(&h1c->px_counters->open_streams); h1s->sess = NULL; h1s->sd = NULL; h1s->flags = H1S_F_WANT_KAL; @@ -1014,7 +1016,6 @@ static struct h1s *h1c_frt_stream_new(struct h1c *h1c, struct stconn *sc, struct if (h1c->px->options2 & PR_O2_REQBUG_OK) h1s->req.err_pos = -1; - HA_ATOMIC_INC(&h1c->px_counters->open_streams); HA_ATOMIC_INC(&h1c->px_counters->total_streams); h1c->idle_exp = TICK_ETERNITY; @@ -1054,7 +1055,6 @@ static struct h1s *h1c_bck_stream_new(struct h1c *h1c, struct stconn *sc, struct if (h1c->px->options2 & PR_O2_RSPBUG_OK) h1s->res.err_pos = -1; - HA_ATOMIC_INC(&h1c->px_counters->open_streams); HA_ATOMIC_INC(&h1c->px_counters->total_streams); TRACE_STATE("created new H1 back stream", H1_EV_H1S_NEW, h1c->conn, h1s);