MINOR: counters: add EXTRA_COUNTERS_BASE() to retrieve extra_counters base storage

The goal is to always retrieve the storage address of the first thread
group for the given module. This will be used to iterate over all thread
groups. For now it returns the same value as EXTRA_COUNTERS_GET().
This commit is contained in:
Willy Tarreau 2026-02-25 10:13:21 +01:00
parent a60e1fcf7f
commit de0eddf512
7 changed files with 12 additions and 6 deletions

View File

@ -104,6 +104,12 @@ void counters_be_shared_drop(struct be_counters_shared *counters);
})
/* Manipulation of extra_counters, for boot-time registrable modules */
/* retrieve the base storage of extra counters (first tgroup if any) */
#define EXTRA_COUNTERS_BASE(counters, mod) \
(likely(counters) ? \
((void *)(*(counters)->datap + (mod)->counters_off[(counters)->type])) : \
(trash_counters))
#define EXTRA_COUNTERS_GET(counters, mod) \
(likely(counters) ? \
((void *)(*(counters)->datap + (mod)->counters_off[(counters)->type])) : \

View File

@ -141,7 +141,7 @@ static int h3_fill_stats(struct stats_module *mod, struct extra_counters *ctr,
if (!ctr)
goto store_metric;
counters = EXTRA_COUNTERS_GET(ctr, mod);
counters = EXTRA_COUNTERS_BASE(ctr, mod);
switch (current_field) {
/* h3 frame type counters */

View File

@ -284,7 +284,7 @@ static int h1_fill_stats(struct stats_module *mod, struct extra_counters *ctr,
if (!ctr)
goto store_metric;
counters = EXTRA_COUNTERS_GET(ctr, mod);
counters = EXTRA_COUNTERS_BASE(ctr, mod);
switch (current_field) {
case H1_ST_OPEN_CONN:

View File

@ -383,7 +383,7 @@ static int h2_fill_stats(struct stats_module *mod, struct extra_counters *ctr,
if (!ctr)
goto store_metric;
counters = EXTRA_COUNTERS_GET(ctr, mod);
counters = EXTRA_COUNTERS_BASE(ctr, mod);
switch (current_field) {
case H2_ST_HEADERS_RCVD:

View File

@ -104,7 +104,7 @@ static int quic_fill_stats(struct stats_module *mod, struct extra_counters *ctr,
if (!ctr)
goto store_metric;
counters = EXTRA_COUNTERS_GET(ctr, mod);
counters = EXTRA_COUNTERS_BASE(ctr, mod);
switch (current_field) {
case QUIC_ST_RXBUF_FULL:

View File

@ -134,7 +134,7 @@ static int resolv_fill_stats(struct stats_module *mod, struct extra_counters *ct
if (!ctr)
goto store_metric;
counters = EXTRA_COUNTERS_GET(ctr, mod);
counters = EXTRA_COUNTERS_BASE(ctr, mod);
switch (current_field) {
case RSLV_STAT_ID:

View File

@ -206,7 +206,7 @@ static int ssl_fill_stats(struct stats_module *mod, struct extra_counters *ctr,
if (!ctr)
goto store_metric;
counters = EXTRA_COUNTERS_GET(ctr, mod);
counters = EXTRA_COUNTERS_BASE(ctr, mod);
switch (current_field) {
case SSL_ST_SESS: