From 4c61e9028cd575ca802ea03e9a3bdde857c81e7a Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Thu, 19 Mar 2026 16:59:23 +0100 Subject: [PATCH] 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. --- src/mworker.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/mworker.c b/src/mworker.c index 261b7578c..d1513f3ac 100644 --- a/src/mworker.c +++ b/src/mworker.c @@ -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); }