From d172f7b923f0468b7c5f3bda3b404e05d2fb860b Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Thu, 12 Mar 2026 17:38:40 +0100 Subject: [PATCH] BUG/MINOR: mworker: only match worker processes when looking for unspawned proc In master-worker mode, when a freshly forked worker looks up its own entry in proc_list to send its "READY" status to the master, the loop was breaking on the first process with pid == -1 regardless of its type. If a non-worker process (e.g. a master or program) also had pid == -1, the wrong entry could be selected, causing send_fd_uxst() to use an invalid ipc_fd. Fix this by adding a PROC_O_TYPE_WORKER check to the loop condition, and add a BUG_ON() assertion to catch any case where the loop exits without finding a valid worker entry. Must be backported to 3.1. --- src/haproxy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/haproxy.c b/src/haproxy.c index f6985f1b6..205c19a06 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -3780,10 +3780,12 @@ int main(int argc, char **argv) } list_for_each_entry(proc, &proc_list, list) { - if (proc->pid == -1) + if (proc->pid == -1 && proc->options & PROC_O_TYPE_WORKER) break; } + BUG_ON(!(proc->options & PROC_O_TYPE_WORKER)); + if (send_fd_uxst(proc->ipc_fd[1], sock_pair[0]) == -1) { ha_alert("[%s.main()] Cannot transfer connection fd %d over the sockpair@%d\n", argv[0], sock_pair[0], proc->ipc_fd[1]);