]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: listeners: move the LI_O_MWORKER flag to the receiver
authorWilly Tarreau <w@1wt.eu>
Fri, 9 Oct 2020 14:11:46 +0000 (16:11 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 9 Oct 2020 16:43:05 +0000 (18:43 +0200)
This listener flag indicates whether the receiver part of the listener
is specific to the master or to the workers. In practice it's only used
by the master's CLI right now. It's used to know whether or not the FD
must be closed before forking the workers. For this reason it's way more
of a receiver's property than a listener's property, so let's move it
there under the name RX_F_MWORKER. The rest of the code remains
unchanged.

include/haproxy/listener-t.h
include/haproxy/receiver-t.h
src/cli.c
src/listener.c
src/mworker.c

index 15328f479f2549f20896f725c4f8f6d7826f4ee8..2181c811fb17997e38bbbb10cf39ef8886364205 100644 (file)
@@ -97,8 +97,8 @@ enum li_state {
 /* unused                       0x0400  */
 /* unused                       0x0800  */
 #define LI_O_ACC_CIP            0x1000  /* find the proxied address in the NetScaler Client IP header */
-/* unused                       0x2000 */
-#define LI_O_MWORKER            0x4000  /* keep the FD open in the master but close it in the children */
+/* unused                       0x2000  */
+/* unused                       0x4000  */
 #define LI_O_NOSTOP             0x8000  /* keep the listener active even after a soft stop */
 
 /* Note: if a listener uses LI_O_UNLIMITED, it is highly recommended that it adds its own
index 7bf15fb347fa864e620dd8a23795f3f7919920e2..6f267ba127aaa1a4f06d32141ac7b00f7e9f59f2 100644 (file)
 #include <haproxy/namespace-t.h>
 #include <haproxy/thread.h>
 
-/* Bit values for receiver->options */
+/* Bit values for receiver->flags */
 #define RX_F_BOUND              0x00000001  /* receiver already bound */
 #define RX_F_INHERITED          0x00000002  /* inherited FD from the parent process (fd@) */
+#define RX_F_MWORKER            0x00000004  /* keep the FD open in the master but close it in the children */
 
 /* Bit values for rx_settings->options */
 #define RX_O_FOREIGN            0x00000001  /* receives on foreign addresses */
index 90320c2e92ce5898a7d86557fa620b664f5f3b4c..7f4ea328a647b98992b132fa57a11a3eba13a2a3 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -2601,7 +2601,8 @@ int mworker_cli_proxy_new_listener(char *line)
                l->accept = session_accept_fd;
                l->default_target = mworker_proxy->default_target;
                /* don't make the peers subject to global limits and don't close it in the master */
-               l->options |= (LI_O_UNLIMITED|LI_O_MWORKER); /* we are keeping this FD in the master */
+               l->options  |= LI_O_UNLIMITED;
+               l->rx.flags |= RX_F_MWORKER; /* we are keeping this FD in the master */
                l->nice = -64;  /* we want to boost priority for local stats */
                global.maxsock++; /* for the listening socket */
        }
index 94db9579e5a0ad5be00aa6ce46beb33ecafabc65..d28b8da4bd32d853827086601655ccea37790a19 100644 (file)
@@ -287,10 +287,8 @@ void enable_listener(struct listener *listener)
         * the workers. Conversely, if it's supposed to be only in the workers
         * close it in the master.
         */
-       if ((master && !(listener->options & LI_O_MWORKER)) ||
-           (!master && (listener->options & LI_O_MWORKER))) {
+       if (!!master != !!(listener->rx.flags & RX_F_MWORKER))
                do_unbind_listener(listener);
-       }
 
        if (listener->state == LI_LISTEN) {
                BUG_ON(listener->rx.fd == -1);
@@ -579,12 +577,12 @@ void do_unbind_listener(struct listener *listener)
         */
 
        if (!stopping && !master &&
-           !(listener->options & LI_O_MWORKER) &&
+           !(listener->rx.flags & RX_F_MWORKER) &&
            (global.tune.options & GTUNE_SOCKET_TRANSFER))
                return;
 
        if (!stopping && master &&
-           listener->options & LI_O_MWORKER &&
+           listener->rx.flags & RX_F_MWORKER &&
            listener->rx.flags & RX_F_INHERITED)
                return;
 
index f3147a18b3b128e577c15b19d115c6c5da60c989..d45b35795236a81d646113ec896bb5542c7077f6 100644 (file)
@@ -422,7 +422,7 @@ void mworker_cleanlisteners()
 
                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)) {
+                       if (!(l->rx.flags & RX_F_MWORKER)) {
                                unbind_listener(l);
                                delete_listener(l);
                        } else {