From: Willy Tarreau Date: Fri, 9 Oct 2020 14:11:46 +0000 (+0200) Subject: MINOR: listeners: move the LI_O_MWORKER flag to the receiver X-Git-Tag: v2.3-dev6~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18c20d28d7efc4ef5b48ce6bd1984ca0c356ff08;p=thirdparty%2Fhaproxy.git MINOR: listeners: move the LI_O_MWORKER flag to the receiver 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. --- diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h index 15328f479f..2181c811fb 100644 --- a/include/haproxy/listener-t.h +++ b/include/haproxy/listener-t.h @@ -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 diff --git a/include/haproxy/receiver-t.h b/include/haproxy/receiver-t.h index 7bf15fb347..6f267ba127 100644 --- a/include/haproxy/receiver-t.h +++ b/include/haproxy/receiver-t.h @@ -29,9 +29,10 @@ #include #include -/* 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 */ diff --git a/src/cli.c b/src/cli.c index 90320c2e92..7f4ea328a6 100644 --- 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 */ } diff --git a/src/listener.c b/src/listener.c index 94db9579e5..d28b8da4bd 100644 --- a/src/listener.c +++ b/src/listener.c @@ -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; diff --git a/src/mworker.c b/src/mworker.c index f3147a18b3..d45b357952 100644 --- a/src/mworker.c +++ b/src/mworker.c @@ -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 {