diff options
author | Piotr Sikora <piotr@cloudflare.com> | 2014-01-30 14:58:21 -0800 |
---|---|---|
committer | Piotr Sikora <piotr@cloudflare.com> | 2014-01-30 14:58:21 -0800 |
commit | 2e57e0609b8cc352fb51df0b0e05309d1cf9589d (patch) | |
tree | 85bd1f6c3701f815f2178a715332893dc87d4c24 | |
parent | 449e8eeb53d33d6a62622b76bf4862ca983b44f3 (diff) | |
download | nginx-2e57e0609b8cc352fb51df0b0e05309d1cf9589d.tar.gz nginx-2e57e0609b8cc352fb51df0b0e05309d1cf9589d.zip |
Core: handle getsockopt(TCP_FASTOPEN) failures.
Linux returns EOPNOTSUPP for non-TCP sockets and ENOPROTOOPT for TCP
sockets, because getsockopt(TCP_FASTOPEN) is not implemented so far.
While there, lower the log level from ALERT to NOTICE to match other
getsockopt() failures.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
-rw-r--r-- | src/core/ngx_connection.c | 12 | ||||
-rw-r--r-- | src/os/unix/ngx_errno.h | 1 | ||||
-rw-r--r-- | src/os/win32/ngx_errno.h | 1 |
3 files changed, 10 insertions, 4 deletions
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c index 21e986c71..15f4f3c90 100644 --- a/src/core/ngx_connection.c +++ b/src/core/ngx_connection.c @@ -97,7 +97,7 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle) ngx_uint_t i; ngx_listening_t *ls; socklen_t olen; -#if (NGX_HAVE_DEFERRED_ACCEPT) +#if (NGX_HAVE_DEFERRED_ACCEPT || NGX_HAVE_TCP_FASTOPEN) ngx_err_t err; #endif #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) @@ -223,9 +223,13 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle) (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); + err = ngx_socket_errno; + + if (err != NGX_EOPNOTSUPP && err != NGX_ENOPROTOOPT) { + ngx_log_error(NGX_LOG_NOTICE, cycle->log, err, + "getsockopt(TCP_FASTOPEN) %V failed, ignored", + &ls[i].addr_text); + } ls[i].fastopen = -1; } diff --git a/src/os/unix/ngx_errno.h b/src/os/unix/ngx_errno.h index 663e460d9..16cafda31 100644 --- a/src/os/unix/ngx_errno.h +++ b/src/os/unix/ngx_errno.h @@ -34,6 +34,7 @@ typedef int ngx_err_t; #define NGX_ENOSPC ENOSPC #define NGX_EPIPE EPIPE #define NGX_EINPROGRESS EINPROGRESS +#define NGX_ENOPROTOOPT ENOPROTOOPT #define NGX_EOPNOTSUPP EOPNOTSUPP #define NGX_EADDRINUSE EADDRINUSE #define NGX_ECONNABORTED ECONNABORTED diff --git a/src/os/win32/ngx_errno.h b/src/os/win32/ngx_errno.h index b1a7b36e5..fd3214563 100644 --- a/src/os/win32/ngx_errno.h +++ b/src/os/win32/ngx_errno.h @@ -38,6 +38,7 @@ typedef DWORD ngx_err_t; #define NGX_EPIPE EPIPE #define NGX_EAGAIN WSAEWOULDBLOCK #define NGX_EINPROGRESS WSAEINPROGRESS +#define NGX_ENOPROTOOPT WSAENOPROTOOPT #define NGX_EOPNOTSUPP WSAEOPNOTSUPP #define NGX_EADDRINUSE WSAEADDRINUSE #define NGX_ECONNABORTED WSAECONNABORTED |