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.
This commit is contained in:
Aurelien DARRAGON 2025-11-11 22:28:53 +01:00
parent a287841578
commit 3262da84ea

View 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