[nginx] Stream: the "fastopen" parameter of the "listen" directive.
Ruslan Ermilov
ru at nginx.com
Thu May 20 17:02:44 UTC 2021
details: https://hg.nginx.org/nginx/rev/2ab7b55ae4a0
branches:
changeset: 7846:2ab7b55ae4a0
user: Ruslan Ermilov <ru at nginx.com>
date: Thu May 20 19:59:16 2021 +0300
description:
Stream: the "fastopen" parameter of the "listen" directive.
Based on a patch by Anbang Wen.
diffstat:
src/stream/ngx_stream.c | 4 ++++
src/stream/ngx_stream.h | 3 +++
src/stream/ngx_stream_core_module.c | 25 +++++++++++++++++++++++++
3 files changed, 32 insertions(+), 0 deletions(-)
diffs (76 lines):
diff -r 5772da03faf8 -r 2ab7b55ae4a0 src/stream/ngx_stream.c
--- a/src/stream/ngx_stream.c Wed May 19 16:24:13 2021 +0300
+++ b/src/stream/ngx_stream.c Thu May 20 19:59:16 2021 +0300
@@ -510,6 +510,10 @@ ngx_stream_optimize_servers(ngx_conf_t *
ls->ipv6only = addr[i].opt.ipv6only;
#endif
+#if (NGX_HAVE_TCP_FASTOPEN)
+ ls->fastopen = addr[i].opt.fastopen;
+#endif
+
#if (NGX_HAVE_REUSEPORT)
ls->reuseport = addr[i].opt.reuseport;
#endif
diff -r 5772da03faf8 -r 2ab7b55ae4a0 src/stream/ngx_stream.h
--- a/src/stream/ngx_stream.h Wed May 19 16:24:13 2021 +0300
+++ b/src/stream/ngx_stream.h Thu May 20 19:59:16 2021 +0300
@@ -65,6 +65,9 @@ typedef struct {
int backlog;
int rcvbuf;
int sndbuf;
+#if (NGX_HAVE_TCP_FASTOPEN)
+ int fastopen;
+#endif
int type;
} ngx_stream_listen_t;
diff -r 5772da03faf8 -r 2ab7b55ae4a0 src/stream/ngx_stream_core_module.c
--- a/src/stream/ngx_stream_core_module.c Wed May 19 16:24:13 2021 +0300
+++ b/src/stream/ngx_stream_core_module.c Thu May 20 19:59:16 2021 +0300
@@ -615,6 +615,10 @@ ngx_stream_core_listen(ngx_conf_t *cf, n
ls->type = SOCK_STREAM;
ls->ctx = cf->ctx;
+#if (NGX_HAVE_TCP_FASTOPEN)
+ ls->fastopen = -1;
+#endif
+
#if (NGX_HAVE_INET6)
ls->ipv6only = 1;
#endif
@@ -635,6 +639,21 @@ ngx_stream_core_listen(ngx_conf_t *cf, n
continue;
}
+#if (NGX_HAVE_TCP_FASTOPEN)
+ if (ngx_strncmp(value[i].data, "fastopen=", 9) == 0) {
+ ls->fastopen = ngx_atoi(value[i].data + 9, value[i].len - 9);
+ ls->bind = 1;
+
+ if (ls->fastopen == NGX_ERROR) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "invalid fastopen \"%V\"", &value[i]);
+ return NGX_CONF_ERROR;
+ }
+
+ continue;
+ }
+#endif
+
if (ngx_strncmp(value[i].data, "backlog=", 8) == 0) {
ls->backlog = ngx_atoi(value[i].data + 8, value[i].len - 8);
ls->bind = 1;
@@ -859,6 +878,12 @@ ngx_stream_core_listen(ngx_conf_t *cf, n
if (ls->proxy_protocol) {
return "\"proxy_protocol\" parameter is incompatible with \"udp\"";
}
+
+#if (NGX_HAVE_TCP_FASTOPEN)
+ if (ls->fastopen != -1) {
+ return "\"fastopen\" parameter is incompatible with \"udp\"";
+ }
+#endif
}
als = cmcf->listen.elts;
More information about the nginx-devel
mailing list