Welcome! Log In Create A New Profile

Advanced

[NGINX] accept4() support SOCK_CLOEXEC flag

张翔
December 16, 2020 02:06AM
# HG changeset patch
# User Zhang Xiang <hawkxiang.cpp@gmail.com>
# Date 1608099124 -28800
# Wed Dec 16 14:12:04 2020 +0800
# Node ID a685d9c04acdb4ec71fd9f176415917c217af630
# Parent 82228f955153527fba12211f52bf102c90f38dfb
Event: accept4() support SOCK_CLOEXEC flag

The close-on-exec flag on the new FD can be set via SOCK_CLOEXEC

diff -r 82228f955153 -r a685d9c04acd auto/unix
--- a/auto/unix Tue Dec 15 17:41:39 2020 +0300
+++ b/auto/unix Wed Dec 16 14:12:04 2020 +0800
@@ -510,7 +510,7 @@
ngx_feature_incs="#include <sys/socket.h>"
ngx_feature_path=
ngx_feature_libs=
-ngx_feature_test="accept4(0, NULL, NULL, SOCK_NONBLOCK)"
+ngx_feature_test="accept4(0, NULL, NULL, SOCK_NONBLOCK | SOCK_CLOEXEC)"
. auto/feature

if [ $NGX_FILE_AIO = YES ]; then
diff -r 82228f955153 -r a685d9c04acd src/event/ngx_event_accept.c
--- a/src/event/ngx_event_accept.c Tue Dec 15 17:41:39 2020 +0300
+++ b/src/event/ngx_event_accept.c Wed Dec 16 14:12:04 2020 +0800
@@ -57,7 +57,7 @@

#if (NGX_HAVE_ACCEPT4)
if (use_accept4) {
- s = accept4(lc->fd, &sa.sockaddr, &socklen, SOCK_NONBLOCK);
+ s = accept4(lc->fd, &sa.sockaddr, &socklen, SOCK_NONBLOCK |
SOCK_CLOEXEC);
} else {
s = accept(lc->fd, &sa.sockaddr, &socklen);
}
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[NGINX] accept4() support SOCK_CLOEXEC flag

张翔 63 December 16, 2020 02:06AM

Re: [NGINX] accept4() support SOCK_CLOEXEC flag

Vladimir Homutov 18 December 16, 2020 02:14AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 60
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready