Hi, On Fri, Dec 15, 2023 at 07:37:47PM +0400, Sergey Kandaurov wrote: > # HG changeset patch > # User Sergey Kandaurov <pluk...@nginx.com> > # Date 1702650289 -14400 > # Fri Dec 15 18:24:49 2023 +0400 > # Node ID cca722e447f8beaaa6b41a620c8b4239a5d1aa7d > # Parent 4d90cb223fdb9e3e6c148726e36cec7835b2f0f8 > Stream: the "deferred" parameter of the "listen" directive. > > The Linux TCP_DEFER_ACCEPT support. > > diff --git a/src/stream/ngx_stream.c b/src/stream/ngx_stream.c > --- a/src/stream/ngx_stream.c > +++ b/src/stream/ngx_stream.c > @@ -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 --git a/src/stream/ngx_stream.h b/src/stream/ngx_stream.h > --- a/src/stream/ngx_stream.h > +++ b/src/stream/ngx_stream.h > @@ -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 --git a/src/stream/ngx_stream_core_module.c > b/src/stream/ngx_stream_core_module.c > --- a/src/stream/ngx_stream_core_module.c > +++ b/src/stream/ngx_stream_core_module.c > @@ -987,6 +987,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) {
We should trigger an error if this option (TCP_DEFER_ACCEPT) is set for UDP. We have a block "if (lsopt.type == SOCK_DGRAM) {}" later in this function. -- Roman Arutyunyan _______________________________________________ nginx-devel mailing list nginx-devel@nginx.org https://mailman.nginx.org/mailman/listinfo/nginx-devel