Hi igor. <div><br></div><div>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 <meta http-equiv="content-type" content="text/html; charset=utf-8">O_NONBLOCK. </div>
<div><br></div><div>And so if use accept4, this will be <meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: Arial; font-size: 14px; line-height: 18px; ">to save twice systemcall, </span><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: Arial; font-size: 14px; line-height: 18px; ">therefore i </span><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: Arial; font-size: 14px; line-height: 18px; ">suggest nginx(in linux </span><span class="Apple-style-span" style="font-family: Arial; font-size: 14px; line-height: 18px; ">platform</span><span class="Apple-style-span" style="font-family: Arial; font-size: 14px; line-height: 18px; ">) should use accept4.</span></div>
<div><span class="Apple-style-span" style="font-family: Arial; font-size: 14px; line-height: 18px; "><br></span></div><div><span class="Apple-style-span" style="font-family: Arial; font-size: 14px; line-height: 18px; "><div>
void</div><div>ngx_event_accept(ngx_event_t *ev)</div><div>{</div><div>.....................................................................</div></span></div><div><font class="Apple-style-span" face="Arial" size="4"><span class="Apple-style-span" style="font-size: 14px; line-height: 18px; ">/* </span></font> replace by s = accept4(lc->fd, (struct sockaddr *) sa, &socklen, O_NONBLOCK); */</div>
<meta http-equiv="content-type" content="text/html; charset=utf-8"><div><span class="Apple-style-span" style="font-family: Arial; font-size: 14px; line-height: 18px; "><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: arial; line-height: normal; font-size: small; "><div>
s = accept(lc->fd, (struct sockaddr *) sa, &socklen);</div><div>..............................................................................................</div><div><div> if (!(ngx_event_flags & (NGX_USE_AIO_EVENT|NGX_USE_RTSIG_EVENT))) {</div>
<div>//if use accept4,this will removed.</div><div> if (ngx_nonblocking(s) == -1) {</div><div> ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_socket_errno,</div><div> ngx_nonblocking_n " failed");</div>
<div> ngx_close_accepted_connection(c);</div><div> return;</div><div> }</div><div> }</div></div><div><br></div><div>thanks!</div></span></span></div><div><span class="Apple-style-span" style="font-family: Arial; font-size: 14px; line-height: 18px; "><br>
</span></div><div><span class="Apple-style-span" style="font-family: Arial; font-size: 14px; line-height: 18px; "><br></span></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><br>-- <br>博观约取<br>
<br>豆瓣:<a href="http://www.douban.com/people/mustang/" target="_blank">www.douban.com/people/mustang/</a><br><br>blog: <a href="http://www.pagefault.info" target="_blank">www.pagefault.info</a><br><br>twitter: <a href="http://www.twitter.com/minibobo" target="_blank">www.twitter.com/minibobo</a><br>
</div>