accept4() support SOCK_CLOEXEC flag
Vladimir Homutov
vl at nginx.com
Wed Dec 16 13:14:53 UTC 2020
16.12.2020 09:41, 张翔 пишет:
> # HG changeset patch
> # User Zhang Xiang <hawkxiang.cpp at gmail.com
> <mailto:hawkxiang.cpp at gmail.com>>
> # Date 1608099124 -28800
> # Wed Dec 16 14:12:04 2020 +0800
> # Node ID a685d9c04acdb4ec71fd9f176415917c217af630
> # Parent 82228f955153527fba12211f52bf102c90f38dfb
> Mail: 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 at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>
just realized you are talking about accepted sockets.
Why do you think it is useful? Normally we don't fork workers and don't
exec anything.
More information about the nginx-devel
mailing list