comparison src/core/ngx_connection.c @ 5431:91bd62a9627e

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 31 Oct 2013 04:00:37 +0400
parents 3d2d3e1cf427
children 692afcea9d0d
comparison
equal deleted inserted replaced
5430:d8ee8ef5dcde 5431:91bd62a9627e
91 { 91 {
92 size_t len; 92 size_t len;
93 ngx_uint_t i; 93 ngx_uint_t i;
94 ngx_listening_t *ls; 94 ngx_listening_t *ls;
95 socklen_t olen; 95 socklen_t olen;
96 #if (NGX_HAVE_DEFERRED_ACCEPT)
97 ngx_err_t err;
98 #endif
96 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) 99 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
97 ngx_err_t err;
98 struct accept_filter_arg af; 100 struct accept_filter_arg af;
99 #endif 101 #endif
100 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT) 102 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
101 int timeout; 103 int timeout;
102 #endif 104 #endif
246 olen = sizeof(int); 248 olen = sizeof(int);
247 249
248 if (getsockopt(ls[i].fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &timeout, &olen) 250 if (getsockopt(ls[i].fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &timeout, &olen)
249 == -1) 251 == -1)
250 { 252 {
251 ngx_log_error(NGX_LOG_NOTICE, cycle->log, ngx_errno, 253 err = ngx_errno;
254
255 if (err == NGX_EOPNOTSUPP) {
256 continue;
257 }
258
259 ngx_log_error(NGX_LOG_NOTICE, cycle->log, err,
252 "getsockopt(TCP_DEFER_ACCEPT) for %V failed, ignored", 260 "getsockopt(TCP_DEFER_ACCEPT) for %V failed, ignored",
253 &ls[i].addr_text); 261 &ls[i].addr_text);
254 continue; 262 continue;
255 } 263 }
256 264