comparison src/event/ngx_event.c @ 6635:6acaa638fa07

Events: support for EPOLLEXCLUSIVE. This flag appeared in Linux 4.5 and is useful for avoiding thundering herd problem. The current Linux kernel implementation walks the list of exclusive waiters, and queues an event to each epfd, until it finds the first waiter that has threads blocked on it via epoll_wait().
author Valentin Bartenev <vbart@nginx.com>
date Fri, 15 Jul 2016 15:18:57 +0300
parents d82b3c344e7e
children a72886067bbb
comparison
equal deleted inserted replaced
6634:18f6120e3b7a 6635:6acaa638fa07
820 #else 820 #else
821 821
822 rev->handler = (c->type == SOCK_STREAM) ? ngx_event_accept 822 rev->handler = (c->type == SOCK_STREAM) ? ngx_event_accept
823 : ngx_event_recvmsg; 823 : ngx_event_recvmsg;
824 824
825 if (ngx_use_accept_mutex
826 #if (NGX_HAVE_REUSEPORT) 825 #if (NGX_HAVE_REUSEPORT)
827 && !ls[i].reuseport 826
828 #endif 827 if (ls[i].reuseport) {
829 ) 828 if (ngx_add_event(rev, NGX_READ_EVENT, 0) == NGX_ERROR) {
829 return NGX_ERROR;
830 }
831
832 continue;
833 }
834
835 #endif
836
837 if (ngx_use_accept_mutex) {
838 continue;
839 }
840
841 #if (NGX_HAVE_EPOLLEXCLUSIVE)
842
843 if ((ngx_event_flags & NGX_USE_EPOLL_EVENT)
844 && ccf->worker_processes > 1)
830 { 845 {
846 if (ngx_add_event(rev, NGX_READ_EVENT, NGX_EXCLUSIVE_EVENT)
847 == NGX_ERROR)
848 {
849 return NGX_ERROR;
850 }
851
831 continue; 852 continue;
832 } 853 }
854
855 #endif
833 856
834 if (ngx_add_event(rev, NGX_READ_EVENT, 0) == NGX_ERROR) { 857 if (ngx_add_event(rev, NGX_READ_EVENT, 0) == NGX_ERROR) {
835 return NGX_ERROR; 858 return NGX_ERROR;
836 } 859 }
837 860