]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mworker: does not add the -sf in wait mode
authorWilliam Lallemand <wlallemand@haproxy.org>
Wed, 24 Nov 2021 23:49:19 +0000 (00:49 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Thu, 25 Nov 2021 09:39:54 +0000 (10:39 +0100)
Since the wait mode is automatically executed after charging the
configuration, -sf was shown in argv[] with the previous PID, which is
normal, but also the current one. This is only a visual problem when
listing the processes, because -sf does not do anything in wait mode.

Fix the issue by removing the whole "-sf" part in wait mode, but the
executed command can be seen in the argv[] of the latest worker forked.

Must be backported in 2.5.

src/haproxy.c

index 343de6e4b0abad77fbaead55d9228f3d578b5494..4dbb283a7853486b593aed83e2eb493dc3efd270 100644 (file)
@@ -720,26 +720,24 @@ static void mworker_reexec()
 
        /* insert the new options just after argv[0] in case we have a -- */
 
-       /* add -sf <PID>*  to argv */
-       if (mworker_child_nb() > 0) {
-               struct mworker_proc *child;
+       if (getenv("HAPROXY_MWORKER_WAIT_ONLY") == NULL) {
+               /* add -sf <PID>*  to argv */
+               if (mworker_child_nb() > 0) {
+                       struct mworker_proc *child;
 
-               next_argv[next_argc++] = "-sf";
+                       next_argv[next_argc++] = "-sf";
 
-               list_for_each_entry(child, &proc_list, list) {
-                       if (!(child->options & PROC_O_LEAVING) && (child->options & PROC_O_TYPE_WORKER))
-                               current_child = child;
+                       list_for_each_entry(child, &proc_list, list) {
+                               if (!(child->options & PROC_O_LEAVING) && (child->options & PROC_O_TYPE_WORKER))
+                                       current_child = child;
 
-                       if (!(child->options & (PROC_O_TYPE_WORKER|PROC_O_TYPE_PROG)) || child->pid <= -1 )
-                               continue;
-                       if ((next_argv[next_argc++] = memprintf(&msg, "%d", child->pid)) == NULL)
-                               goto alloc_error;
-                       msg = NULL;
+                               if (!(child->options & (PROC_O_TYPE_WORKER|PROC_O_TYPE_PROG)) || child->pid <= -1)
+                                       continue;
+                               if ((next_argv[next_argc++] = memprintf(&msg, "%d", child->pid)) == NULL)
+                                       goto alloc_error;
+                               msg = NULL;
+                       }
                }
-       }
-
-
-       if (getenv("HAPROXY_MWORKER_WAIT_ONLY") == NULL) {
 
                if (current_child) {
                        /* add the -x option with the socketpair of the current worker */