|
|
|
@ -30,48 +30,6 @@ index 10835f6c..b5b33bb3 100644
|
|
|
|
|
+ fd = socket(AF_INET, SOCK_STREAM, 0);
|
|
|
|
|
+ fcntl(fd, F_SETFD, FD_CLOEXEC);"
|
|
|
|
|
+. auto/feature
|
|
|
|
|
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
|
|
|
|
|
index 9a747589..3c0a90c5 100644
|
|
|
|
|
--- a/src/core/ngx_connection.c
|
|
|
|
|
+++ b/src/core/ngx_connection.c
|
|
|
|
|
@@ -450,8 +450,15 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+#if (NGX_HAVE_SOCKET_CLOEXEC)
|
|
|
|
|
+ s = ngx_socket(ls[i].sockaddr->sa_family,
|
|
|
|
|
+ ls[i].type | SOCK_CLOEXEC, 0);
|
|
|
|
|
+
|
|
|
|
|
+#else
|
|
|
|
|
s = ngx_socket(ls[i].sockaddr->sa_family, ls[i].type, 0);
|
|
|
|
|
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
if (s == (ngx_socket_t) -1) {
|
|
|
|
|
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
|
|
|
|
ngx_socket_n " %V failed", &ls[i].addr_text);
|
|
|
|
|
@@ -536,6 +543,21 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+#if (NGX_HAVE_FD_CLOEXEC)
|
|
|
|
|
+ if (ngx_cloexec(s) == -1) {
|
|
|
|
|
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
|
|
|
|
+ ngx_cloexec_n " %V failed", &ls[i].addr_text);
|
|
|
|
|
+
|
|
|
|
|
+ if (ngx_close_socket(s) == -1) {
|
|
|
|
|
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
|
|
|
|
+ ngx_close_socket_n " %V failed",
|
|
|
|
|
+ &ls[i].addr_text);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return NGX_ERROR;
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
ngx_log_debug2(NGX_LOG_DEBUG_CORE, log, 0,
|
|
|
|
|
"bind() %V #%d ", &ls[i].addr_text, s);
|
|
|
|
|
|
|
|
|
|
diff --git a/src/core/ngx_resolver.c b/src/core/ngx_resolver.c
|
|
|
|
|
index cd55520c..438e0806 100644
|
|
|
|
|
--- a/src/core/ngx_resolver.c
|
|
|
|
|