summaryrefslogtreecommitdiffhomepage
path: root/src/event/ngx_event.c
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2021-12-30 01:08:46 +0300
committerMaxim Dounin <mdounin@mdounin.ru>2021-12-30 01:08:46 +0300
commit96c342e56035a9676180d03b4659d5b05b9c6b07 (patch)
treeb723bd96fa33a0aeb570cbbfd6121d0b94289193 /src/event/ngx_event.c
parent614726621797f1267c41f8a8e488eeefff8bdf7f (diff)
downloadnginx-96c342e56035a9676180d03b4659d5b05b9c6b07.tar.gz
nginx-96c342e56035a9676180d03b4659d5b05b9c6b07.tar.bz2
Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Linux with EPOLLEXCLUSIVE usually notifies only the process which was first to add the listening socket to the epoll instance. As a result most of the connections are handled by the first worker process (ticket #2285). To fix this, we re-add the socket periodically, so other workers will get a chance to accept connections.
Diffstat (limited to 'src/event/ngx_event.c')
-rw-r--r--src/event/ngx_event.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index 0d187ca33..47229b507 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -55,6 +55,7 @@ ngx_uint_t ngx_accept_events;
ngx_uint_t ngx_accept_mutex_held;
ngx_msec_t ngx_accept_mutex_delay;
ngx_int_t ngx_accept_disabled;
+ngx_uint_t ngx_use_exclusive_accept;
#if (NGX_STAT_STUB)
@@ -644,6 +645,8 @@ ngx_event_process_init(ngx_cycle_t *cycle)
#endif
+ ngx_use_exclusive_accept = 0;
+
ngx_queue_init(&ngx_posted_accept_events);
ngx_queue_init(&ngx_posted_next_events);
ngx_queue_init(&ngx_posted_events);
@@ -889,6 +892,8 @@ ngx_event_process_init(ngx_cycle_t *cycle)
if ((ngx_event_flags & NGX_USE_EPOLL_EVENT)
&& ccf->worker_processes > 1)
{
+ ngx_use_exclusive_accept = 1;
+
if (ngx_add_event(rev, NGX_READ_EVENT, NGX_EXCLUSIVE_EVENT)
== NGX_ERROR)
{