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