comparison src/event/modules/ngx_epoll_module.c @ 4305:f68047884e83

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).
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 22 Nov 2011 17:02:21 +0000
parents a3203c4521c6
children f40541f7afb5
comparison
equal deleted inserted replaced
4304:ed922fb9d6c1 4305:f68047884e83
679 } 679 }
680 } 680 }
681 681
682 wev = c->write; 682 wev = c->write;
683 683
684 if (c->fd == -1 || wev->instance != instance) {
685
686 /*
687 * the stale event from a file descriptor
688 * that was just closed in this iteration
689 */
690
691 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
692 "epoll: stale event %p", c);
693 continue;
694 }
695
684 if ((revents & EPOLLOUT) && wev->active) { 696 if ((revents & EPOLLOUT) && wev->active) {
685 697
686 if (flags & NGX_POST_THREAD_EVENTS) { 698 if (flags & NGX_POST_THREAD_EVENTS) {
687 wev->posted_ready = 1; 699 wev->posted_ready = 1;
688 700