]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: stats-file: fix shm-stats-file preload not working anymore
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 11 Nov 2025 21:28:53 +0000 (22:28 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Tue, 11 Nov 2025 21:36:17 +0000 (22:36 +0100)
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

index 4152726aefbda5a83b7192e5bdef5cac9370252c..eadb160ce66be3298d8b305676d2319990e26ec6 100644 (file)
@@ -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