From 84f5c2136ecb351ff873dcd1d70df49e25570320 Mon Sep 17 00:00:00 2001 From: Mathew Rodley Date: Tue, 3 Dec 2013 22:07:03 +0400 Subject: Added support for TCP_FASTOPEN supported in Linux >= 3.7.1. --- auto/unix | 12 ++++++++++++ src/core/ngx_connection.c | 32 ++++++++++++++++++++++++++++++++ src/core/ngx_connection.h | 4 ++++ src/http/ngx_http.c | 4 ++++ src/http/ngx_http_core_module.c | 21 +++++++++++++++++++++ src/http/ngx_http_core_module.h | 3 +++ 6 files changed, 76 insertions(+) --- src/http/ngx_http.c | 4 ++++ src/http/ngx_http_core_module.c | 23 +++++++++++++++++++++++ src/http/ngx_http_core_module.h | 3 +++ 3 files changed, 30 insertions(+) (limited to 'src/http') diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c index 91bb04f55..f030baa71 100644 --- a/src/http/ngx_http.c +++ b/src/http/ngx_http.c @@ -1811,6 +1811,10 @@ ngx_http_add_listening(ngx_conf_t *cf, ngx_http_conf_addr_t *addr) ls->setfib = addr->opt.setfib; #endif +#if (NGX_HAVE_TCP_FASTOPEN) + ls->fastopen = addr->opt.fastopen; +#endif + return ls; } diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 4e5c78e9b..8abf864d5 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -3040,6 +3040,9 @@ ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy) lsopt.sndbuf = -1; #if (NGX_HAVE_SETFIB) lsopt.setfib = -1; +#endif +#if (NGX_HAVE_TCP_FASTOPEN) + lsopt.fastopen = -1; #endif lsopt.wildcard = 1; @@ -3988,6 +3991,9 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) lsopt.sndbuf = -1; #if (NGX_HAVE_SETFIB) lsopt.setfib = -1; +#endif +#if (NGX_HAVE_TCP_FASTOPEN) + lsopt.fastopen = -1; #endif lsopt.wildcard = u.wildcard; #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) @@ -4027,6 +4033,23 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) continue; } #endif + +#if (NGX_HAVE_TCP_FASTOPEN) + if (ngx_strncmp(value[n].data, "fastopen=", 9) == 0) { + lsopt.fastopen = ngx_atoi(value[n].data + 9, value[n].len - 9); + lsopt.set = 1; + lsopt.bind = 1; + + if (lsopt.fastopen == NGX_ERROR) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "invalid fastopen \"%V\"", &value[n]); + return NGX_CONF_ERROR; + } + + continue; + } +#endif + if (ngx_strncmp(value[n].data, "backlog=", 8) == 0) { lsopt.backlog = ngx_atoi(value[n].data + 8, value[n].len - 8); lsopt.set = 1; diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h index 5b38000d8..220c94ee4 100644 --- a/src/http/ngx_http_core_module.h +++ b/src/http/ngx_http_core_module.h @@ -89,6 +89,9 @@ typedef struct { #if (NGX_HAVE_SETFIB) int setfib; #endif +#if (NGX_HAVE_TCP_FASTOPEN) + int fastopen; +#endif #if (NGX_HAVE_KEEPALIVE_TUNABLE) int tcp_keepidle; int tcp_keepintvl; -- cgit