diff options
author | Sergey Kandaurov <pluknet@nginx.com> | 2025-05-26 16:11:36 +0400 |
---|---|---|
committer | pluknet <pluknet@nginx.com> | 2025-05-27 01:59:02 +0400 |
commit | 5b8a5c08ce28639e788734b2528faad70baa113c (patch) | |
tree | fd3f3029d17f3f15913db39d017651c0996acb78 /src/event/ngx_event_accept.c | |
parent | 3d5889a3ee41a282bad54d9c0d3662dba9f52c1b (diff) | |
download | nginx-master.tar.gz nginx-master.zip |
The support first appeared in OS X Mavericks 10.9 and documented since
OS X Yosemite 10.10.
It has a subtle implementation difference from other operating systems
in that the TCP_KEEPALIVE socket option (used in place of TCP_KEEPIDLE)
isn't inherited from a listening socket to an accepted socket.
An apparent reason for this behaviour is that it might be preserved for
the sake of backward compatibility. The TCP_KEEPALIVE socket option is
not inherited since appearance in OS X Panther 10.3, which long predates
two other TCP_KEEPINTVL and TCP_KEEPCNT socket options.
Thanks to Andy Pan for initial work.
Diffstat (limited to 'src/event/ngx_event_accept.c')
-rw-r--r-- | src/event/ngx_event_accept.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/event/ngx_event_accept.c b/src/event/ngx_event_accept.c index 27038799d..033d7e021 100644 --- a/src/event/ngx_event_accept.c +++ b/src/event/ngx_event_accept.c @@ -203,6 +203,23 @@ ngx_event_accept(ngx_event_t *ev) } } +#if (NGX_HAVE_KEEPALIVE_TUNABLE && NGX_DARWIN) + + /* Darwin doesn't inherit TCP_KEEPALIVE from a listening socket */ + + if (ls->keepidle) { + if (setsockopt(s, IPPROTO_TCP, TCP_KEEPALIVE, + (const void *) &ls->keepidle, sizeof(int)) + == -1) + { + ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_socket_errno, + "setsockopt(TCP_KEEPALIVE, %d) failed, ignored", + ls->keepidle); + } + } + +#endif + *log = ls->log; c->recv = ngx_recv; |