]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mworker: only match worker processes when looking for unspawned proc
authorWilliam Lallemand <wlallemand@haproxy.com>
Thu, 12 Mar 2026 16:38:40 +0000 (17:38 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Fri, 13 Mar 2026 08:13:11 +0000 (09:13 +0100)
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

index f6985f1b616df964aa3f252cad445be8adcf8072..205c19a06c438743b71d5b78f3a3b395925cdc9c 100644 (file)
@@ -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]);