]> git.kaiwu.me - haproxy.git/commit
CLEANUP: counters: only retrieve zeroes for unallocated extra_counters
authorWilly Tarreau <w@1wt.eu>
Wed, 25 Feb 2026 13:24:33 +0000 (14:24 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 26 Feb 2026 07:24:03 +0000 (08:24 +0100)
commit8dd22a62a43bf2476835a0c14c2f9f45d57c0e99
tree3d9ea9927e74d767be2c7e1bec943e47972e220e
parent95a9f472d2cb9c8f525ca8275e149393e11eea48
CLEANUP: counters: only retrieve zeroes for unallocated extra_counters

Since version 2.4 with commit 7f8f6cb926 ("BUG/MEDIUM: stats: prevent
crash if counters not alloc with dummy one") we can afford to always
update extra_counters because we know they're always either allocated
or linked to a dedicated trash. However, the ->fill_stats() callbacks
continue to access such values, making it technically possible to
retrieve random counters from this trash, which is not really clean.
Let's implement an explicit test in the ->fill_stats() functions to
only return 0 for the metric when not allocated like this. It's much
cleaner because it guarantees that we're returning an empty counter
in this case rather than random values.

The situation currently happens for dummy servers like the ones used
in Lua proxies as well as those used by rings (e.g. used for logging
or traces). Normally, none of the objects retrieved via stats or
Prometheus is concerned by this unallocated extra_counters situation,
so this is more about a cleanup than a real fix.
src/h3_stats.c
src/mux_h1.c
src/mux_h2.c
src/quic_stats.c
src/resolvers.c
src/ssl_sock.c