]> git.kaiwu.me - nginx.git/commitdiff
Merge of r4306, r4320:
authorMaxim Dounin <mdounin@mdounin.ru>
Sat, 4 Feb 2012 23:18:12 +0000 (23:18 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Sat, 4 Feb 2012 23:18:12 +0000 (23:18 +0000)
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.

src/event/modules/ngx_epoll_module.c

index 31c10c6dc86f76c0047ccb4271f890063e41f269..f4003af70359b4a32c589c7b58de1b49c5fe3dd8 100644 (file)
@@ -683,6 +683,18 @@ ngx_epoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t flags)
 
         if ((revents & EPOLLOUT) && wev->active) {
 
+            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 (flags & NGX_POST_THREAD_EVENTS) {
                 wev->posted_ready = 1;