aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/ngx_connection.c4
-rw-r--r--src/event/ngx_event_accept.c17
2 files changed, 21 insertions, 0 deletions
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
index 75809d9ad..7cae295eb 100644
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -765,6 +765,8 @@ ngx_configure_listening_sockets(ngx_cycle_t *cycle)
#if (NGX_HAVE_KEEPALIVE_TUNABLE)
+#if !(NGX_DARWIN)
+
if (ls[i].keepidle) {
value = ls[i].keepidle;
@@ -782,6 +784,8 @@ ngx_configure_listening_sockets(ngx_cycle_t *cycle)
}
}
+#endif
+
if (ls[i].keepintvl) {
value = ls[i].keepintvl;
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;