From 43046fa4f4d467f77fd557ad7c73b8e8f5c352d4 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 1 Sep 2020 15:41:59 +0200 Subject: [PATCH] MINOR: listener: move the INHERITED flag down to the receiver It's the receiver's FD that's inherited from the parent process, not the listener's so the flag must move to the receiver so that appropriate actions can be taken. --- include/haproxy/listener-t.h | 2 +- include/haproxy/receiver-t.h | 1 + src/cli.c | 2 +- src/listener.c | 2 +- src/mworker.c | 2 +- src/proto_tcp.c | 2 +- src/proto_uxst.c | 2 +- src/proxy.c | 2 +- 8 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h index 36c8cbb..45c5a11 100644 --- a/include/haproxy/listener-t.h +++ b/include/haproxy/listener-t.h @@ -97,7 +97,7 @@ enum li_state { #define LI_O_V6ONLY 0x0400 /* bind to IPv6 only on Linux >= 2.4.21 */ #define LI_O_V4V6 0x0800 /* bind to IPv4/IPv6 on Linux >= 2.4.21 */ #define LI_O_ACC_CIP 0x1000 /* find the proxied address in the NetScaler Client IP header */ -#define LI_O_INHERITED 0x2000 /* inherited FD from the parent process (fd@) */ +/* unused 0x2000 */ #define LI_O_MWORKER 0x4000 /* keep the FD open in the master but close it in the children */ #define LI_O_NOSTOP 0x8000 /* keep the listener active even after a soft stop */ diff --git a/include/haproxy/receiver-t.h b/include/haproxy/receiver-t.h index 5537d5a..babad44 100644 --- a/include/haproxy/receiver-t.h +++ b/include/haproxy/receiver-t.h @@ -31,6 +31,7 @@ /* Bit values for receiver->options */ #define RX_F_BOUND 0x00000001 /* receiver already bound */ +#define RX_F_INHERITED 0x00000002 /* inherited FD from the parent process (fd@) */ /* All the settings that are used to configure a receiver */ struct rx_settings { diff --git a/src/cli.c b/src/cli.c index 4cf4cc1..977d857 100644 --- a/src/cli.c +++ b/src/cli.c @@ -2671,7 +2671,7 @@ int mworker_cli_sockpair_new(struct mworker_proc *mworker_proc, int proc) l->default_target = global.stats_fe->default_target; l->options |= (LI_O_UNLIMITED | LI_O_NOSTOP); /* it's a sockpair but we don't want to keep the fd in the master */ - l->options &= ~LI_O_INHERITED; + l->rx.flags &= ~RX_F_INHERITED; 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 27476cd..ededb1a 100644 --- a/src/listener.c +++ b/src/listener.c @@ -574,7 +574,7 @@ int create_listeners(struct bind_conf *bc, const struct sockaddr_storage *ss, proto->add(l, port); if (inherited) - l->options |= LI_O_INHERITED; + l->rx.flags |= RX_F_INHERITED; HA_SPIN_INIT(&l->lock); _HA_ATOMIC_ADD(&jobs, 1); diff --git a/src/mworker.c b/src/mworker.c index 1caec10..d6365e1 100644 --- a/src/mworker.c +++ b/src/mworker.c @@ -426,7 +426,7 @@ void mworker_cleanlisteners() /* unbind the listener but does not close if the FD is inherited with fd@ from the parent process */ - if (l->options & LI_O_INHERITED) + if (l->rx.flags & RX_F_INHERITED) unbind_listener_no_close(l); else unbind_listener(l); diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 84b3635..fe0fdca 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -777,7 +777,7 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen) thread_mask(listener->rx.settings->bind_thread) & all_threads_mask); /* for now, all regularly bound TCP listeners are exportable */ - if (!(listener->options & LI_O_INHERITED)) + if (!(listener->rx.flags & RX_F_INHERITED)) fdtab[fd].exported = 1; tcp_return: diff --git a/src/proto_uxst.c b/src/proto_uxst.c index 4378db3..5cabea2 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -270,7 +270,7 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle thread_mask(listener->rx.settings->bind_thread) & all_threads_mask); /* for now, all regularly bound UNIX listeners are exportable */ - if (!(listener->options & LI_O_INHERITED)) + if (!(listener->rx.flags & RX_F_INHERITED)) fdtab[fd].exported = 1; return err; diff --git a/src/proxy.c b/src/proxy.c index 3f25dac..21d11ee 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -1370,7 +1370,7 @@ void stop_proxy(struct proxy *p) continue; } /* The master should not close an inherited FD */ - if (master && (l->options & LI_O_INHERITED)) + if (master && (l->rx.flags & RX_F_INHERITED)) unbind_listener_no_close(l); else unbind_listener(l); -- 1.7.10.4