summaryrefslogtreecommitdiffhomepage
path: root/src/core/ngx_connection.c
diff options
context:
space:
mode:
authorMathew Rodley <mathew@rodley.com.au>2013-12-03 22:07:03 +0400
committerMathew Rodley <mathew@rodley.com.au>2013-12-03 22:07:03 +0400
commit84f5c2136ecb351ff873dcd1d70df49e25570320 (patch)
treeaaebc231eeffafdec8266913d2a4875e42126d1b /src/core/ngx_connection.c
parenta8a7de3f78390a19952a4a9bb253548895850e9e (diff)
downloadnginx-84f5c2136ecb351ff873dcd1d70df49e25570320.tar.gz
nginx-84f5c2136ecb351ff873dcd1d70df49e25570320.tar.bz2
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(+)
Diffstat (limited to 'src/core/ngx_connection.c')
-rw-r--r--src/core/ngx_connection.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
index fbcd5f719..4544b294a 100644
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -82,6 +82,10 @@ ngx_create_listening(ngx_conf_t *cf, void *sockaddr, socklen_t socklen)
ls->setfib = -1;
#endif
+#if (NGX_HAVE_TCP_FASTOPEN)
+ ls->fastopen = -1;
+#endif
+
return ls;
}
@@ -209,6 +213,21 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle)
#endif
#endif
+#if (NGX_HAVE_TCP_FASTOPEN)
+
+ if (getsockopt(ls[i].fastopen, IPPROTO_TCP, TCP_FASTOPEN,
+ (void *) &ls[i].fastopen, &olen)
+ == -1)
+ {
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
+ "getsockopt(TCP_FASTOPEN) %V failed, ignored",
+ &ls[i].addr_text);
+
+ ls[i].fastopen = -1;
+ }
+
+#endif
+
#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
ngx_memzero(&af, sizeof(struct accept_filter_arg));
@@ -582,6 +601,19 @@ ngx_configure_listening_sockets(ngx_cycle_t *cycle)
}
#endif
+#if (NGX_HAVE_TCP_FASTOPEN)
+ if (ls[i].fastopen != -1) {
+ if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_FASTOPEN,
+ (const void *) &ls[i].fastopen, sizeof(int))
+ == -1)
+ {
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
+ "setsockopt(TCP_FASTOPEN, %d) %V failed, ignored",
+ ls[i].fastopen, &ls[i].addr_text);
+ }
+ }
+#endif
+
#if 0
if (1) {
int tcp_nodelay = 1;