diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2011-11-22 17:02:21 +0000 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2011-11-22 17:02:21 +0000 |
commit | 7f59728d5b78268ff94f9d3ab464022b48d0f6ea (patch) | |
tree | f6ee69c1086e3f284470433a10a53b4b5f1c179b /src | |
parent | 0560ae55bccfd14c1abc76f1282ed46c324fb771 (diff) | |
download | nginx-7f59728d5b78268ff94f9d3ab464022b48d0f6ea.tar.gz nginx-7f59728d5b78268ff94f9d3ab464022b48d0f6ea.zip |
Protection from stale write events in epoll.
Stale write event may happen if epoll_wait() reported both read and write
events, and processing of the read event closed descriptor.
Patch by Yichun Zhang (agentzh).
Diffstat (limited to 'src')
-rw-r--r-- | src/event/modules/ngx_epoll_module.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/event/modules/ngx_epoll_module.c b/src/event/modules/ngx_epoll_module.c index 31c10c6dc..4f9c5118e 100644 --- a/src/event/modules/ngx_epoll_module.c +++ b/src/event/modules/ngx_epoll_module.c @@ -681,6 +681,18 @@ ngx_epoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t flags) wev = c->write; + if (c->fd == -1 || wev->instance != instance) { + + /* + * the stale event from a file descriptor + * that was just closed in this iteration + */ + + ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, + "epoll: stale event %p", c); + continue; + } + if ((revents & EPOLLOUT) && wev->active) { if (flags & NGX_POST_THREAD_EVENTS) { |