BUG/MINOR: mworker: fix sort order of mworker_proc in 'show proc'

Since version 3.1, the display order of old workers in 'show proc' was
accidentally reversed. The oldest worker was shown first and the newest
last, which was not the intended behavior. This regression was introduced
during the master-worker rework.

Fix this by sorting the list during deserialization in
mworker_env_to_proc_list().

An alternative fix would have been to iterate the list in reverse order
in the show proc function, but that approach risks introducing
inconsistencies when backporting to older versions.

Must be backported to 3.1 and later.
This commit is contained in:
William Lallemand 2026-03-19 16:59:23 +01:00
parent 932d77e287
commit 4c61e9028c

View file

@ -223,7 +223,20 @@ int mworker_env_to_proc_list()
}
}
if (child->pid > 0) {
LIST_APPEND(&proc_list, &child->list);
struct list *insert_pt = &proc_list;
struct mworker_proc *pos;
/* insert at the right position in ASC reload order;
* search from the tail since items are sorted most of
* the time
*/
list_for_each_entry_rev(pos, &proc_list, list) {
if (pos->reloads <= child->reloads) {
insert_pt = &pos->list;
break;
}
}
LIST_INSERT(insert_pt, &child->list);
} else {
mworker_free_child(child);
}