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

vbart at nginx.com vbart at nginx.com
Fri Apr 12 15:02:33 UTC 2013


Author: vbart
Date: 2013-04-12 15:02:33 +0000 (Fri, 12 Apr 2013)
New Revision: 5171
URL: http://trac.nginx.org/nginx/changeset/5171/nginx

Log:
Events: protection from stale events in eventport and devpoll.

Stale write event may happen if read and write events was reported both,
and processing of the read event closed descriptor.

In practice this might result in "sendfilev() failed (134: ..." or
"writev() failed (134: ..." errors when switching to next upstream server.

See report here:
http://mailman.nginx.org/pipermail/nginx/2013-April/038421.html


Modified:
   trunk/src/event/modules/ngx_devpoll_module.c
   trunk/src/event/modules/ngx_eventport_module.c

Modified: trunk/src/event/modules/ngx_devpoll_module.c
===================================================================
--- trunk/src/event/modules/ngx_devpoll_module.c	2013-04-11 13:49:13 UTC (rev 5170)
+++ trunk/src/event/modules/ngx_devpoll_module.c	2013-04-12 15:02:33 UTC (rev 5171)
@@ -343,7 +343,7 @@
     ngx_fd_t            fd;
     ngx_err_t           err;
     ngx_int_t           i;
-    ngx_uint_t          level;
+    ngx_uint_t          level, instance;
     ngx_event_t        *rev, *wev, **queue;
     ngx_connection_t   *c;
     struct pollfd       pfd;
@@ -510,7 +510,13 @@
                 ngx_locked_post_event(rev, queue);
 
             } else {
+                instance = rev->instance;
+
                 rev->handler(rev);
+
+                if (c->fd == -1 || wev->instance != instance) {
+                    continue;
+                }
             }
         }
 

Modified: trunk/src/event/modules/ngx_eventport_module.c
===================================================================
--- trunk/src/event/modules/ngx_eventport_module.c	2013-04-11 13:49:13 UTC (rev 5170)
+++ trunk/src/event/modules/ngx_eventport_module.c	2013-04-12 15:02:33 UTC (rev 5171)
@@ -551,7 +551,7 @@
                 } else {
                     rev->handler(rev);
 
-                    if (ev->closed) {
+                    if (ev->closed || ev->instance != instance) {
                         continue;
                     }
                 }



More information about the nginx-devel mailing list