]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: counters: add EXTRA_COUNTERS_BASE() to retrieve extra_counters base storage
authorWilly Tarreau <w@1wt.eu>
Wed, 25 Feb 2026 09:13:21 +0000 (10:13 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 26 Feb 2026 16:03:53 +0000 (17:03 +0100)
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().

include/haproxy/counters.h
src/h3_stats.c
src/mux_h1.c
src/mux_h2.c
src/quic_stats.c
src/resolvers.c
src/ssl_sock.c

index 5fbe94d6fbe44714288e17bd2ba60d0c4ad1bf80..26d2ebe5322aa8746bb9c096165ba29b85674cd4 100644 (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])) : \
index f82c7042283561f19d5bb5204abaefcd2b17d57c..16453f25dc46e144c6725f453bd2f611c18ca3d5 100644 (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 */
index b37d2b6927a94887fa43aba291313d40d6b386f3..94a773c719181873a32492b10256e5e6d1928dc3 100644 (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:
index fdbf9613b5dfa29a9fba471ce5eae37a0cbe7727..21d6155283fd6c9477666e94241d5b1a08d60ab2 100644 (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:
index 0dc6b632d2ecaca03850fc3cf6c69fd02962765d..7e7e1aaee1d952051dc5adc256e0273d686a2c8f 100644 (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:
index c717b013a9dea9ad86aa9c01cf1f5962cf6d7484..b8306d33df82dda2f723da8333895f89a04feb30 100644 (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:
index 510798e5509662e426a235b6da8870c4af0d38c0..4fbfcb4dd052a02233d28c9e097ac5240e0dc111 100644 (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: