accept4 should be used in nginx( linux platform)

Maxim Dounin mdounin at
Sun Nov 7 18:12:44 MSK 2010


On Sun, Nov 07, 2010 at 10:30:41PM +0800, BoBo wrote:

> The accept4() system call is available starting with Linux 2.6.28; support
> in glibc is available starting with version 2.10.  It can transport the
> O_NONBLOCK flags in accept, and in nginx( in linux) after accept fd,
> call fcntl(twice) set fd to O_NONBLOCK.
> And so if use accept4, this will be to save twice systemcall,
> therefore i suggest
> nginx(in  linux platform) should use accept4.

Yes, this make sense for Linux as it has no inheritance for 
O_NONBLOCK from listening socket.  Care to provide patch?

Just random implementation thoughs: probably emulating 
NGX_HAVE_INHERITED_NONBLOCK via accept4() is a right way to go.

Maxim Dounin

More information about the nginx mailing list