Skip to content

Commit

Permalink
epoll: don't miss poll events under high load
Browse files Browse the repository at this point in the history
If multiple epoll sources generate events simultaneously, it is possible
for more jobs to be added to particular priority level than will be
handled in one go by qb_loop_run_level(). If one of these epoll sources
gains a new event (say, by switching from "readable" to "readable and
writeable"), then this new event would be missed.

To fix this, merge new epoll events into revents regardless of whether
the job is on the joblist. When the job is dispatched, revents will be
cleared, or the epoll source will be deleted entirely.
  • Loading branch information
Michael Chapman committed Jun 5, 2014
1 parent f8b4a1b commit 2a06ffe
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/loop_poll_epoll.c
Expand Up @@ -178,16 +178,12 @@ _poll_and_add_to_jobs_(struct qb_loop_source *src, int32_t ms_timeout)
*/
continue;
}
if (events[i].events == pe->ufd.revents ||
pe->state == QB_POLL_ENTRY_JOBLIST) {
/*
* entry already in the job queue.
*/
continue;
}
pe->ufd.revents = _epoll_to_poll_event_(events[i].events);

new_jobs += pe->add_to_jobs(src->l, pe);
pe->ufd.revents |= _epoll_to_poll_event_(events[i].events);

if (pe->state != QB_POLL_ENTRY_JOBLIST) {
new_jobs += pe->add_to_jobs(src->l, pe);
}
}

return new_jobs;
Expand Down

0 comments on commit 2a06ffe

Please sign in to comment.