Welcome! Log In Create A New Profile

Advanced

[nginx] Stream: the "deferred" parameter of the "listen" directive.

Sergey Kandaurov
March 22, 2024 07:20AM
details: https://hg.nginx.org/nginx/rev/bed832296f5d
branches:
changeset: 9221:bed832296f5d
user: Sergey Kandaurov <pluknet@nginx.com>
date: Fri Mar 22 14:53:19 2024 +0400
description:
Stream: the "deferred" parameter of the "listen" directive.

The Linux TCP_DEFER_ACCEPT support.

diffstat:

src/stream/ngx_stream.c | 4 ++++
src/stream/ngx_stream.h | 1 +
src/stream/ngx_stream_core_module.c | 19 +++++++++++++++++++
3 files changed, 24 insertions(+), 0 deletions(-)

diffs (61 lines):

diff -r c8cf6b1cc82e -r bed832296f5d src/stream/ngx_stream.c
--- a/src/stream/ngx_stream.c Fri Mar 22 14:53:19 2024 +0400
+++ b/src/stream/ngx_stream.c Fri Mar 22 14:53:19 2024 +0400
@@ -1021,6 +1021,10 @@ ngx_stream_add_listening(ngx_conf_t *cf,
ls->keepcnt = addr->opt.tcp_keepcnt;
#endif

+#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
+ ls->deferred_accept = addr->opt.deferred_accept;
+#endif
+
#if (NGX_HAVE_INET6)
ls->ipv6only = addr->opt.ipv6only;
#endif
diff -r c8cf6b1cc82e -r bed832296f5d src/stream/ngx_stream.h
--- a/src/stream/ngx_stream.h Fri Mar 22 14:53:19 2024 +0400
+++ b/src/stream/ngx_stream.h Fri Mar 22 14:53:19 2024 +0400
@@ -53,6 +53,7 @@ typedef struct {
#if (NGX_HAVE_INET6)
unsigned ipv6only:1;
#endif
+ unsigned deferred_accept:1;
unsigned reuseport:1;
unsigned so_keepalive:2;
unsigned proxy_protocol:1;
diff -r c8cf6b1cc82e -r bed832296f5d src/stream/ngx_stream_core_module.c
--- a/src/stream/ngx_stream_core_module.c Fri Mar 22 14:53:19 2024 +0400
+++ b/src/stream/ngx_stream_core_module.c Fri Mar 22 14:53:19 2024 +0400
@@ -1015,6 +1015,19 @@ ngx_stream_core_listen(ngx_conf_t *cf, n
continue;
}

+ if (ngx_strcmp(value[i].data, "deferred") == 0) {
+#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
+ lsopt.deferred_accept = 1;
+ lsopt.set = 1;
+ lsopt.bind = 1;
+#else
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "the deferred accept is not supported "
+ "on this platform, ignored");
+#endif
+ continue;
+ }
+
if (ngx_strncmp(value[i].data, "ipv6only=o", 10) == 0) {
#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
if (ngx_strcmp(&value[i].data[10], "n") == 0) {
@@ -1173,6 +1186,12 @@ ngx_stream_core_listen(ngx_conf_t *cf, n
return "\"backlog\" parameter is incompatible with \"udp\"";
}

+#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
+ if (lsopt.deferred_accept) {
+ return "\"deferred\" parameter is incompatible with \"udp\"";
+ }
+#endif
+
#if (NGX_STREAM_SSL)
if (lsopt.ssl) {
return "\"ssl\" parameter is incompatible with \"udp\"";
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Stream: the "deferred" parameter of the "listen" directive.

Sergey Kandaurov 124 March 22, 2024 07:20AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 175
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready