From 644b6b99255d4e853c195446b703bcdb2d1e8e18 Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Tue, 16 Sep 2025 18:30:51 +0200 Subject: [PATCH] MINOR: counters: document that tg shared counters are tied to shm-stats-file mapping Let's explicitly mention that fe_counters_shared_tg and be_counters_shared_tg structs are embedded in shm_stats_file_object struct so any change in those structs will result in shm stats file incompatibility between processes, thus extra precaution must be taken when making changes to them. Note that the provisionning made in shm_stats_file_object struct could be used to add members to {fe,be}_counters_shared_tg without changing shm_stats_file_object struct size if needed in order to preserve shm stats file version. --- include/haproxy/counters-t.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/include/haproxy/counters-t.h b/include/haproxy/counters-t.h index 18eb58919..13dd8f88a 100644 --- a/include/haproxy/counters-t.h +++ b/include/haproxy/counters-t.h @@ -33,6 +33,11 @@ struct { \ uint16_t flags; /* COUNTERS_SHARED_F flags */\ }; + +/* /!\ any change performed here will impact shm-stats-file mapping because the + * struct is embedded in shm_stats_file_object struct, so proceed with caution + * and change shm stats file version if needed + */ #define COUNTERS_SHARED_TG \ struct { \ unsigned long last_state_change; /* last time, when the state was changed */\ @@ -60,7 +65,11 @@ struct counters_shared { } *tg[MAX_TGROUPS]; }; -/* counters used by listeners and frontends */ +/* + * /!\ any change performed here will impact shm-stats-file mapping because the + * struct is embedded in shm_stats_file_object struct, so proceed with caution + * and change shm stats file version if needed + */ struct fe_counters_shared_tg { COUNTERS_SHARED_TG; @@ -91,6 +100,7 @@ struct fe_counters_shared { struct fe_counters_shared_tg *tg[MAX_TGROUPS]; }; +/* counters used by listeners and frontends */ struct fe_counters { struct fe_counters_shared shared; /* shared counters */ unsigned int conn_max; /* max # of active sessions */ @@ -108,6 +118,10 @@ struct fe_counters { } p; /* protocol-specific stats */ }; +/* /!\ any change performed here will impact shm-stats-file mapping because the + * struct is embedded in shm_stats_file_object struct, so proceed with caution + * and change shm stats file version if needed + */ struct be_counters_shared_tg { COUNTERS_SHARED_TG;