Mercurial > hg > nginx
diff src/core/ngx_connection.c @ 5456:692afcea9d0d
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(+)
author | Mathew Rodley <mathew@rodley.com.au> |
---|---|
date | Tue, 03 Dec 2013 22:07:03 +0400 |
parents | 91bd62a9627e |
children | 1ab1cf63f885 |
line wrap: on
line diff
--- a/src/core/ngx_connection.c Tue Dec 03 21:44:08 2013 +0400 +++ b/src/core/ngx_connection.c Tue Dec 03 22:07:03 2013 +0400 @@ -82,6 +82,10 @@ ls->setfib = -1; #endif +#if (NGX_HAVE_TCP_FASTOPEN) + ls->fastopen = -1; +#endif + return ls; } @@ -209,6 +213,21 @@ #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 @@ } #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;