From 3262da84ea2a8d657737f01ef045253ad199a3db Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Tue, 11 Nov 2025 22:28:53 +0100 Subject: [PATCH] BUG/MEDIUM: stats-file: fix shm-stats-file preload not working anymore Due to recent commit 5c299dee ("MEDIUM: stats: consider that shared stats pointers may be NULL") shm-stats-file preloading suddenly stopped working In fact preloading should be considered as an initializing step so the counters may be assigned there without checking for NULL first. Indeed there are supposed to be NULL because preloading occurs before counters_{fe,be}_shared_prepare() which takes care of setting the pointers for counters if they weren't set before. Obviously this corner-case was overlooked during 5c299dee writing and testing. Thanks to Nick Ramirez for having reported the issue. No backport needed, this issue is specific to 3.3. --- src/stats-file.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/stats-file.c b/src/stats-file.c index 4152726ae..eadb160ce 100644 --- a/src/stats-file.c +++ b/src/stats-file.c @@ -765,7 +765,7 @@ static void shm_stats_file_preload(void) BUG_ON(curr_obj->type != SHM_STATS_FILE_OBJECT_TYPE_FE); li = __objt_listener(node->obj_type); // counters are optional for listeners - if (li->counters && li->counters->shared.tg[obj_tgid - 1]) + if (li->counters) li->counters->shared.tg[obj_tgid - 1] = &curr_obj->data.fe; break; } @@ -775,8 +775,7 @@ static void shm_stats_file_preload(void) BUG_ON(curr_obj->type != SHM_STATS_FILE_OBJECT_TYPE_BE); sv = __objt_server(node->obj_type); - if (sv->counters.shared.tg[obj_tgid - 1]) - sv->counters.shared.tg[obj_tgid - 1] = &curr_obj->data.be; + sv->counters.shared.tg[obj_tgid - 1] = &curr_obj->data.be; break; } case OBJ_TYPE_PROXY: @@ -784,11 +783,9 @@ static void shm_stats_file_preload(void) struct proxy *px; px = __objt_proxy(node->obj_type); - if (curr_obj->type == SHM_STATS_FILE_OBJECT_TYPE_FE && - px->fe_counters.shared.tg[obj_tgid - 1]) + if (curr_obj->type == SHM_STATS_FILE_OBJECT_TYPE_FE) px->fe_counters.shared.tg[obj_tgid - 1] = &curr_obj->data.fe; - else if (curr_obj->type == SHM_STATS_FILE_OBJECT_TYPE_BE && - px->be_counters.shared.tg[obj_tgid - 1]) + else if (curr_obj->type == SHM_STATS_FILE_OBJECT_TYPE_BE) px->be_counters.shared.tg[obj_tgid - 1] = &curr_obj->data.be; else goto release; // not supported