BUG/MINOR: startup: set GTUNE_SOCKET_TRANSFER correctly
authorWilliam Lallemand <wlallemand@haproxy.com>
Mon, 20 Nov 2023 09:49:05 +0000 (10:49 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Mon, 20 Nov 2023 09:49:05 +0000 (10:49 +0100)
This bug was forbidding the GTUNE_SOCKET_TRANSFER option to be set
when haproxy is neither in daemon mode nor in mworker mode. So it
basically only impacts the foreground mode.

The fix moves the code outside the 'if (global.mode & (MODE_DAEMON |
MODE_MWORKER | MODE_MWORKER_WAIT))' condition.

Bug was introduced with 7f80eb23 ("MEDIUM: proxy: zombify proxies only
when the expose-fd socket is bound").

Must be backported in every stable version.

src/haproxy.c

index 1fa7b80..33e8ae8 100644 (file)
@@ -3750,22 +3750,6 @@ int main(int argc, char **argv)
                ha_free(&global.chroot);
                set_identity(argv[0]);
 
-               /* pass through every cli socket, and check if it's bound to
-                * the current process and if it exposes listeners sockets.
-                * Caution: the GTUNE_SOCKET_TRANSFER is now set after the fork.
-                * */
-
-               if (global.cli_fe) {
-                       struct bind_conf *bind_conf;
-
-                       list_for_each_entry(bind_conf, &global.cli_fe->conf.bind, by_fe) {
-                               if (bind_conf->level & ACCESS_FD_LISTENERS) {
-                                       global.tune.options |= GTUNE_SOCKET_TRANSFER;
-                                       break;
-                               }
-                       }
-               }
-
                /*
                 * This is only done in daemon mode because we might want the
                 * logs on stdout in mworker mode. If we're NOT in QUIET mode,
@@ -3787,6 +3771,22 @@ int main(int argc, char **argv)
                fork_poller();
        }
 
+       /* pass through every cli socket, and check if it's bound to
+        * the current process and if it exposes listeners sockets.
+        * Caution: the GTUNE_SOCKET_TRANSFER is now set after the fork.
+        * */
+
+       if (global.cli_fe) {
+               struct bind_conf *bind_conf;
+
+               list_for_each_entry(bind_conf, &global.cli_fe->conf.bind, by_fe) {
+                       if (bind_conf->level & ACCESS_FD_LISTENERS) {
+                               global.tune.options |= GTUNE_SOCKET_TRANSFER;
+                               break;
+                       }
+               }
+       }
+
        /* Note that here we can't be in the parent/master anymore */
 #if !defined(USE_THREAD) && defined(USE_CPU_AFFINITY)
        if (ha_cpuset_count(&cpu_map[0].thread[0])) {   /* only do this if the process has a CPU map */