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.
}
}
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);
}