]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mworker: remove the initialization loop over processes
authorWilly Tarreau <w@1wt.eu>
Tue, 15 Jun 2021 06:02:06 +0000 (08:02 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 15 Jun 2021 14:52:42 +0000 (16:52 +0200)
There was a loop used to prepare structures for all current processes.
Let's just assume there's a single iteration now.

src/haproxy.c

index 93e098e50488c0d8e08188e0a0265a2e1cfeab10..c4f2c9be8c4c53dc4bdd6e67f3022c05046c70da 100644 (file)
@@ -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;