[nginx] svn commit: r4306 - trunk/src/event/modules

mdounin at mdounin.ru mdounin at mdounin.ru
Tue Nov 22 17:02:22 UTC 2011


Author: mdounin
Date: 2011-11-22 17:02:21 +0000 (Tue, 22 Nov 2011)
New Revision: 4306

Log:
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).


Modified:
   trunk/src/event/modules/ngx_epoll_module.c

Modified: trunk/src/event/modules/ngx_epoll_module.c
===================================================================
--- trunk/src/event/modules/ngx_epoll_module.c	2011-11-22 16:27:45 UTC (rev 4305)
+++ trunk/src/event/modules/ngx_epoll_module.c	2011-11-22 17:02:21 UTC (rev 4306)
@@ -681,6 +681,18 @@
 
         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) {



More information about the nginx-devel mailing list