Mercurial > nginx
changeset 9221:bed832296f5d
Stream: the "deferred" parameter of the "listen" directive.
The Linux TCP_DEFER_ACCEPT support.
| author | Sergey Kandaurov <pluknet@nginx.com> |
|---|---|
| date | Fri, 22 Mar 2024 14:53:19 +0400 |
| parents | c8cf6b1cc82e |
| children | c78790d3d061 |
| files | src/stream/ngx_stream.c src/stream/ngx_stream.h src/stream/ngx_stream_core_module.c |
| diffstat | 3 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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
--- 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 @@ #if (NGX_HAVE_INET6) unsigned ipv6only:1; #endif + unsigned deferred_accept:1; unsigned reuseport:1; unsigned so_keepalive:2; unsigned proxy_protocol:1;
--- 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 @@ 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 @@ 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\"";
