]> git.kaiwu.me - haproxy.git/commit
MEDIUM: counters: store the number of thread groups accessing extra_counters
authorWilly Tarreau <w@1wt.eu>
Wed, 25 Feb 2026 15:06:21 +0000 (16:06 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 26 Feb 2026 16:03:53 +0000 (17:03 +0100)
commita60e1fcf7f1d937a429485eae2995f75ff56288e
tree45f53973f647df387625507279639689a4f3677e
parent7ac47910a2cab91baf8b60d9ce024c110aeadd3b
MEDIUM: counters: store the number of thread groups accessing extra_counters

In order to be able to properly allocate all storage and retrieve data
from there, we'll need to know how many thread groups are supposed to
access it. Let's store the number of thread groups at init time. If the
tgrp_step is zero, there's always only one tg though.

Now EXTRA_COUNTERS_ALLOC() takes this number of thread groups in argument
and stores it in the structure. It also allocates as many areas as needed,
incrementing the datap pointer by the step for each of them.

EXTRA_COUNTERS_FREE() uses this info to free all allocated areas.

EXTRA_COUNTERS_INIT() initializes all allocated areas, this is used
elsewhere to clear/preset counters, e.g. in proxy_stats_clear_counters().
It involves a memcpy() call for each array, which is normally preset to
something empty but might also be used to preset certain non-scalar
fields such as an instance name.
include/haproxy/counters-t.h
include/haproxy/counters.h
src/resolvers.c
src/stats.c