From: Willy Tarreau Date: Tue, 15 Jun 2021 06:02:06 +0000 (+0200) Subject: MINOR: mworker: remove the initialization loop over processes X-Git-Tag: v2.5-dev1~121 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6185a0343bd74a8fb4321083fe709938bf756b11;p=thirdparty%2Fhaproxy.git MINOR: mworker: remove the initialization loop over processes There was a loop used to prepare structures for all current processes. Let's just assume there's a single iteration now. --- diff --git a/src/haproxy.c b/src/haproxy.c index 93e098e504..c4f2c9be8c 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -1903,7 +1903,6 @@ static void init(int argc, char **argv) } if (global.mode & MODE_MWORKER) { - int proc; struct mworker_proc *tmproc; setenv("HAPROXY_MWORKER", "1", 1); @@ -1928,28 +1927,25 @@ static void init(int argc, char **argv) LIST_APPEND(&proc_list, &tmproc->list); } - for (proc = 0; proc < global.nbproc; proc++) { - - tmproc = calloc(1, sizeof(*tmproc)); - if (!tmproc) { - ha_alert("Cannot allocate process structures.\n"); - exit(EXIT_FAILURE); - } - - tmproc->options |= PROC_O_TYPE_WORKER; /* worker */ - tmproc->pid = -1; - tmproc->reloads = 0; - tmproc->timestamp = -1; - tmproc->relative_pid = 1 + proc; - tmproc->ipc_fd[0] = -1; - tmproc->ipc_fd[1] = -1; + tmproc = calloc(1, sizeof(*tmproc)); + if (!tmproc) { + ha_alert("Cannot allocate process structures.\n"); + exit(EXIT_FAILURE); + } - if (mworker_cli_sockpair_new(tmproc, proc) < 0) { - exit(EXIT_FAILURE); - } + tmproc->options |= PROC_O_TYPE_WORKER; /* worker */ + tmproc->pid = -1; + tmproc->reloads = 0; + tmproc->timestamp = -1; + tmproc->relative_pid = 1; + tmproc->ipc_fd[0] = -1; + tmproc->ipc_fd[1] = -1; - LIST_APPEND(&proc_list, &tmproc->list); + if (mworker_cli_sockpair_new(tmproc, 0) < 0) { + exit(EXIT_FAILURE); } + + LIST_APPEND(&proc_list, &tmproc->list); } if (global.mode & (MODE_MWORKER|MODE_MWORKER_WAIT)) { struct wordlist *it, *c;