]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: mworker: move mworker_cleanlisteners to mworker.c
authorWilliam Lallemand <wlallemand@haproxy.com>
Mon, 1 Apr 2019 09:29:57 +0000 (11:29 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 1 Apr 2019 12:45:37 +0000 (14:45 +0200)
include/proto/mworker.h
src/haproxy.c
src/mworker.c

index becb123a1df226f4a0bb7a6e47e1c1ccb18f27f2..3b3e28066f0778c208d6fcf17d833d9ea7c14fcc 100644 (file)
@@ -29,6 +29,8 @@ void mworker_catch_sigchld(struct sig_handler *sh);
 void mworker_accept_wrapper(int fd);
 void mworker_pipe_register();
 
+void mworker_cleanlisteners();
+
 extern int *children; /* store PIDs of children in master workers mode */
 
 #endif /* PROTO_MWORKER_H_ */
index 52bf2be836270f0e2692c62484bdbe3564edb2c6..3cc5c9ca509d591a0c8162c4072689ec9cc01853 100644 (file)
@@ -494,58 +494,6 @@ int tell_old_pids(int sig)
        return ret;
 }
 
-
-/*
- * Upon a reload, the master worker needs to close all listeners FDs but the mworker_pipe
- * fd, and the FD provided by fd@
- */
-static void mworker_cleanlisteners()
-{
-       struct listener *l, *l_next;
-       struct proxy *curproxy;
-       struct peers *curpeers;
-
-       /* we might have to unbind some peers sections from some processes */
-       for (curpeers = cfg_peers; curpeers; curpeers = curpeers->next) {
-               if (!curpeers->peers_fe)
-                       continue;
-
-               stop_proxy(curpeers->peers_fe);
-               /* disable this peer section so that it kills itself */
-               signal_unregister_handler(curpeers->sighandler);
-               task_delete(curpeers->sync_task);
-               task_free(curpeers->sync_task);
-               curpeers->sync_task = NULL;
-               task_free(curpeers->peers_fe->task);
-               curpeers->peers_fe->task = NULL;
-               curpeers->peers_fe = NULL;
-       }
-
-       for (curproxy = proxies_list; curproxy; curproxy = curproxy->next) {
-               int listen_in_master = 0;
-
-               list_for_each_entry_safe(l, l_next, &curproxy->conf.listeners, by_fe) {
-                       /* remove the listener, but not those we need in the master... */
-                       if (!(l->options & LI_O_MWORKER)) {
-                               /* unbind the listener but does not close if
-                                  the FD is inherited with fd@ from the parent
-                                  process */
-                               if (l->options & LI_O_INHERITED)
-                                       unbind_listener_no_close(l);
-                               else
-                                       unbind_listener(l);
-                               delete_listener(l);
-                       } else {
-                               listen_in_master = 1;
-                       }
-               }
-               /* if the proxy shouldn't be in the master, we stop it */
-               if (!listen_in_master)
-                       curproxy->state = PR_STSTOPPED;
-       }
-}
-
-
 /*
  * remove a pid forom the olpid array and decrease nb_oldpids
  * return 1 pid was found otherwise return 0
index 786cc44e745bacee7a9220a258ccf58c230a5850..0d46884f08ff01ec659cea36e0908099c7b63fff 100644 (file)
@@ -26,6 +26,8 @@
 #include <proto/signal.h>
 
 #include <types/global.h>
+#include <types/peers.h>
+#include <proto/proxy.h>
 #include <types/signal.h>
 
 #if defined(USE_SYSTEMD)
@@ -301,3 +303,54 @@ void mworker_pipe_register()
        fd_insert(proc_self->ipc_fd[1], fdtab[proc_self->ipc_fd[1]].owner, mworker_accept_wrapper, 1);
        fd_want_recv(proc_self->ipc_fd[1]);
 }
+
+/* ----- proxies ----- */
+/*
+ * Upon a reload, the master worker needs to close all listeners FDs but the mworker_pipe
+ * fd, and the FD provided by fd@
+ */
+void mworker_cleanlisteners()
+{
+       struct listener *l, *l_next;
+       struct proxy *curproxy;
+       struct peers *curpeers;
+
+       /* we might have to unbind some peers sections from some processes */
+       for (curpeers = cfg_peers; curpeers; curpeers = curpeers->next) {
+               if (!curpeers->peers_fe)
+                       continue;
+
+               stop_proxy(curpeers->peers_fe);
+               /* disable this peer section so that it kills itself */
+               signal_unregister_handler(curpeers->sighandler);
+               task_delete(curpeers->sync_task);
+               task_free(curpeers->sync_task);
+               curpeers->sync_task = NULL;
+               task_free(curpeers->peers_fe->task);
+               curpeers->peers_fe->task = NULL;
+               curpeers->peers_fe = NULL;
+       }
+
+       for (curproxy = proxies_list; curproxy; curproxy = curproxy->next) {
+               int listen_in_master = 0;
+
+               list_for_each_entry_safe(l, l_next, &curproxy->conf.listeners, by_fe) {
+                       /* remove the listener, but not those we need in the master... */
+                       if (!(l->options & LI_O_MWORKER)) {
+                               /* unbind the listener but does not close if
+                                  the FD is inherited with fd@ from the parent
+                                  process */
+                               if (l->options & LI_O_INHERITED)
+                                       unbind_listener_no_close(l);
+                               else
+                                       unbind_listener(l);
+                               delete_listener(l);
+                       } else {
+                               listen_in_master = 1;
+                       }
+               }
+               /* if the proxy shouldn't be in the master, we stop it */
+               if (!listen_in_master)
+                       curproxy->state = PR_STSTOPPED;
+       }
+}