From: Valentine Krasnobaeva Date: Fri, 22 Nov 2024 21:39:20 +0000 (+0100) Subject: REORG: startup: move on_new_child_failure in mworker.c X-Git-Tag: v3.1.0~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=af642420b4e13ac2e8dd8ff0efd55386280df704;p=thirdparty%2Fhaproxy.git REORG: startup: move on_new_child_failure in mworker.c 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. --- diff --git a/include/haproxy/global.h b/include/haproxy/global.h index d3cc12221a..40ec67af95 100644 --- a/include/haproxy/global.h +++ b/include/haproxy/global.h @@ -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) diff --git a/src/haproxy.c b/src/haproxy.c index 4b880b81cd..25881ce90a 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -914,31 +914,6 @@ static void mworker_loop() run_thread_poll_loop(NULL); } -/* - * 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. */ diff --git a/src/mworker.c b/src/mworker.c index ffd4840574..ebe032efd1 100644 --- a/src/mworker.c +++ b/src/mworker.c @@ -313,6 +313,31 @@ void mworker_catch_sigterm(struct sig_handler *sh) mworker_kill(sig); } +/* + * 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 */