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.
This commit is contained in:
Willy Tarreau 2020-10-09 16:11:46 +02:00
parent 75c98d166e
commit 18c20d28d7
5 changed files with 10 additions and 10 deletions

View 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

View File

@ -29,9 +29,10 @@
#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 */

View File

@ -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 */
}

View 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;

View 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 {