Welcome! Log In Create A New Profile

Advanced

accept4 should be used in nginx( linux platform)

BoBo
November 07, 2010 09:34AM
Hi igor.

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.

void
ngx_event_accept(ngx_event_t *ev)
{
......................................................................
/* replace by s = accept4(lc->fd, (struct sockaddr *) sa, &socklen,
O_NONBLOCK); */
s = accept(lc->fd, (struct sockaddr *) sa, &socklen);
................................................................................................
if (!(ngx_event_flags &
(NGX_USE_AIO_EVENT|NGX_USE_RTSIG_EVENT))) {
//if use accept4,this will removed.
if (ngx_nonblocking(s) == -1) {
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_socket_errno,
ngx_nonblocking_n " failed");
ngx_close_accepted_connection(c);
return;
}
}

thanks!



--
博观约取

豆瓣:www.douban.com/people/mustang/

blog: www.pagefault.info

twitter: www.twitter.com/minibobo
_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

accept4 should be used in nginx( linux platform)

BoBo November 07, 2010 09:34AM

Re: accept4 should be used in nginx( linux platform)

Maxim Dounin November 07, 2010 10:16AM

Re: accept4 should be used in nginx( linux platform)

BoBo November 07, 2010 11:40AM

Re: accept4 should be used in nginx( linux platform)

Maxim Dounin November 07, 2010 12:38PM

Re: accept4 should be used in nginx( linux platform)

Simon Liu November 07, 2010 01:04PM

Re: accept4 should be used in nginx( linux platform)

Maxim Dounin November 07, 2010 01:10PM

Re: accept4 should be used in nginx( linux platform)

muratpisat January 02, 2011 05:14AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 307
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready