[nginx] Core: handling of getsockopt(TCP_DEFER_ACCEPT) failures.

Maxim Dounin mdounin at mdounin.ru
Thu Oct 31 00:01:07 UTC 2013


details:   http://hg.nginx.org/nginx/rev/91bd62a9627e
branches:  
changeset: 5431:91bd62a9627e
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Thu Oct 31 04:00:37 2013 +0400
description:
Core: handling of getsockopt(TCP_DEFER_ACCEPT) failures.

Recent Linux versions started to return EOPNOTSUPP to getsockopt() calls
on unix sockets, resulting in log pollution on binary upgrade.  Such errors
are silently ignored now.

diffstat:

 src/core/ngx_connection.c |  12 ++++++++++--
 src/os/unix/ngx_errno.h   |   1 +
 src/os/win32/ngx_errno.h  |   1 +
 3 files changed, 12 insertions(+), 2 deletions(-)

diffs (52 lines):

diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -93,8 +93,10 @@ ngx_set_inherited_sockets(ngx_cycle_t *c
     ngx_uint_t                 i;
     ngx_listening_t           *ls;
     socklen_t                  olen;
+#if (NGX_HAVE_DEFERRED_ACCEPT)
+    ngx_err_t                  err;
+#endif
 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
-    ngx_err_t                  err;
     struct accept_filter_arg   af;
 #endif
 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
@@ -248,7 +250,13 @@ ngx_set_inherited_sockets(ngx_cycle_t *c
         if (getsockopt(ls[i].fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &timeout, &olen)
             == -1)
         {
-            ngx_log_error(NGX_LOG_NOTICE, cycle->log, ngx_errno,
+            err = ngx_errno;
+
+            if (err == NGX_EOPNOTSUPP) {
+                continue;
+            }
+
+            ngx_log_error(NGX_LOG_NOTICE, cycle->log, err,
                           "getsockopt(TCP_DEFER_ACCEPT) for %V failed, ignored",
                           &ls[i].addr_text);
             continue;
diff --git a/src/os/unix/ngx_errno.h b/src/os/unix/ngx_errno.h
--- 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_EOPNOTSUPP    EOPNOTSUPP
 #define NGX_EADDRINUSE    EADDRINUSE
 #define NGX_ECONNABORTED  ECONNABORTED
 #define NGX_ECONNRESET    ECONNRESET
diff --git a/src/os/win32/ngx_errno.h b/src/os/win32/ngx_errno.h
--- a/src/os/win32/ngx_errno.h
+++ b/src/os/win32/ngx_errno.h
@@ -38,6 +38,7 @@ typedef DWORD                      ngx_e
 #define NGX_EPIPE                  EPIPE
 #define NGX_EAGAIN                 WSAEWOULDBLOCK
 #define NGX_EINPROGRESS            WSAEINPROGRESS
+#define NGX_EOPNOTSUPP             WSAEOPNOTSUPP
 #define NGX_EADDRINUSE             WSAEADDRINUSE
 #define NGX_ECONNABORTED           WSAECONNABORTED
 #define NGX_ECONNRESET             WSAECONNRESET



More information about the nginx-devel mailing list