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.
}
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;
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;
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);