REORG: startup: move on_new_child_failure in mworker.c
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Fri, 22 Nov 2024 21:39:20 +0000 (22:39 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Mon, 25 Nov 2024 14:20:24 +0000 (15:20 +0100)
mworker_on_new_child_failure() performs some routines for the worker process,
if it has failed the reload. As it's called only in mworker_catch_sigchld()
from mworker.c, let's move mworker_on_new_child_failure() in mworker.c as well.
Like this it could also be declared as a static.

include/haproxy/global.h
src/haproxy.c
src/mworker.c

index d3cc122..40ec67a 100644 (file)
@@ -68,7 +68,6 @@ void display_version();
 
 void mworker_accept_wrapper(int fd);
 void mworker_reload(int hardreload);
-void mworker_on_new_child_failure(void);
 
 /* to be used with warned and WARN_* */
 static inline int already_warned(unsigned int warning)
index 4b880b8..25881ce 100644 (file)
@@ -915,31 +915,6 @@ static void mworker_loop()
 }
 
 /*
- * Performs some routines for the worker process, which has failed the reload,
- * updates the global load_status.
- */
-void mworker_on_new_child_failure()
-{
-       struct mworker_proc *child;
-
-       /* increment the number of failed reloads */
-       list_for_each_entry(child, &proc_list, list) {
-               child->failedreloads++;
-       }
-
-       /* do not keep unused FDs retrieved from the previous process */
-       sock_drop_unused_old_sockets();
-
-       usermsgs_clr(NULL);
-       load_status = 0;
-       ha_warning("Failed to load worker!\n");
-       /* the sd_notify API is not able to send a reload failure signal. So
-        * the READY=1 signal still need to be sent */
-       if (global.tune.options & GTUNE_USE_SYSTEMD)
-               sd_notify(0, "READY=1\nSTATUS=Reload failed!\n");
-}
-
-/*
  * Exit with an error message upon a master recovery mode failure.
  */
 static void exit_on_failure()
index ffd4840..ebe032e 100644 (file)
@@ -314,6 +314,31 @@ void mworker_catch_sigterm(struct sig_handler *sh)
 }
 
 /*
+ * Performs some routines for the worker process, which has failed the reload,
+ * updates the global load_status.
+ */
+static void mworker_on_new_child_failure()
+{
+       struct mworker_proc *child;
+
+       /* increment the number of failed reloads */
+       list_for_each_entry(child, &proc_list, list) {
+               child->failedreloads++;
+       }
+
+       /* do not keep unused FDs retrieved from the previous process */
+       sock_drop_unused_old_sockets();
+
+       usermsgs_clr(NULL);
+       load_status = 0;
+       ha_warning("Failed to load worker!\n");
+       /* the sd_notify API is not able to send a reload failure signal. So
+        * the READY=1 signal still need to be sent */
+       if (global.tune.options & GTUNE_USE_SYSTEMD)
+               sd_notify(0, "READY=1\nSTATUS=Reload failed!\n");
+}
+
+/*
  * Wait for every children to exit
  */