aboutsummaryrefslogtreecommitdiff
path: root/src/stream/ngx_stream_core_module.c
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@nginx.com>2021-05-20 19:59:16 +0300
committerRuslan Ermilov <ru@nginx.com>2021-05-20 19:59:16 +0300
commitecbe06b9fee57207d84be9ac39d1aa10b2d0fbd8 (patch)
tree6eb0fcf583842b4b9b12cb299dc9c154bf1d7c06 /src/stream/ngx_stream_core_module.c
parent6029e211c63895c44a942bacc32c6d2f565cc3e3 (diff)
downloadnginx-ecbe06b9fee57207d84be9ac39d1aa10b2d0fbd8.tar.gz
nginx-ecbe06b9fee57207d84be9ac39d1aa10b2d0fbd8.zip
Stream: the "fastopen" parameter of the "listen" directive.
Based on a patch by Anbang Wen.
Diffstat (limited to 'src/stream/ngx_stream_core_module.c')
-rw-r--r--src/stream/ngx_stream_core_module.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/stream/ngx_stream_core_module.c b/src/stream/ngx_stream_core_module.c
index 9b6afe974..d96d27ab5 100644
--- a/src/stream/ngx_stream_core_module.c
+++ b/src/stream/ngx_stream_core_module.c
@@ -615,6 +615,10 @@ ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
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, ngx_command_t *cmd, void *conf)
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, ngx_command_t *cmd, void *conf)
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;