From: Willy Tarreau Date: Thu, 12 Jan 2023 18:37:07 +0000 (+0100) Subject: MINOR: listener: move the NOLINGER option to the bind_conf X-Git-Tag: v2.8-dev3~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cfb7c2f5155f055bd53488074a1c2e71afb1e6ac;p=thirdparty%2Fhaproxy.git MINOR: listener: move the NOLINGER option to the bind_conf It's currently declared per-frontend, though it would make sense to support it per-line but in no case per-listener. Let's move the option to a bind_conf option BC_O_NOLINGER. --- diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h index 33d7541bee..8322ef4c68 100644 --- a/include/haproxy/listener-t.h +++ b/include/haproxy/listener-t.h @@ -92,7 +92,7 @@ enum li_status { /* listener socket options */ #define LI_O_NONE 0x0000 -#define LI_O_NOLINGER 0x0001 /* disable linger on this socket */ +/* unused 0x0001 */ /* unused 0x0002 */ #define LI_O_NOQUICKACK 0x0004 /* disable quick ack of immediate data (linux) */ #define LI_O_DEF_ACCEPT 0x0008 /* wait up to 1 second for data before accepting */ @@ -121,6 +121,7 @@ enum li_status { #define BC_O_USE_SOCK_STREAM 0x00000010 /* at least one stream-type listener is used */ #define BC_O_USE_XPRT_DGRAM 0x00000020 /* at least one dgram-only xprt listener is used */ #define BC_O_USE_XPRT_STREAM 0x00000040 /* at least one stream-only xprt listener is used */ +#define BC_O_NOLINGER 0x00000080 /* disable lingering on these listeners */ /* flags used with bind_conf->ssl_options */ diff --git a/src/cfgparse.c b/src/cfgparse.c index 666d5c33b5..6b0a1e56d9 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -4288,6 +4288,8 @@ init_proxies_list_stage2: if (!bind_conf->maxaccept) bind_conf->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : MAX_ACCEPT; bind_conf->accept = session_accept_fd; + if (curproxy->options & PR_O_TCP_NOLING) + bind_conf->options |= BC_O_NOLINGER; } /* adjust this proxy's listeners */ @@ -4310,9 +4312,6 @@ init_proxies_list_stage2: memprintf(&listener->name, "sock-%d", listener->luid); } - if (curproxy->options & PR_O_TCP_NOLING) - listener->options |= LI_O_NOLINGER; - #ifdef USE_QUIC if (listener->flags & LI_F_QUIC_LISTENER) { if (!global.cluster_secret) { diff --git a/src/proto_tcp.c b/src/proto_tcp.c index dca1f8d7a4..30135cc30e 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -605,7 +605,7 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen) fd = listener->rx.fd; - if (listener->options & LI_O_NOLINGER) + if (listener->bind_conf->options & BC_O_NOLINGER) setsockopt(fd, SOL_SOCKET, SO_LINGER, &nolinger, sizeof(struct linger)); else { struct linger tmplinger;