Skip to content

Commit 2a06ffe

Browse files
author
Michael Chapman
committed
epoll: don't miss poll events under high load
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.
1 parent f8b4a1b commit 2a06ffe

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

lib/loop_poll_epoll.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,12 @@ _poll_and_add_to_jobs_(struct qb_loop_source *src, int32_t ms_timeout)
178178
*/
179179
continue;
180180
}
181-
if (events[i].events == pe->ufd.revents ||
182-
pe->state == QB_POLL_ENTRY_JOBLIST) {
183-
/*
184-
* entry already in the job queue.
185-
*/
186-
continue;
187-
}
188-
pe->ufd.revents = _epoll_to_poll_event_(events[i].events);
189181

190-
new_jobs += pe->add_to_jobs(src->l, pe);
182+
pe->ufd.revents |= _epoll_to_poll_event_(events[i].events);
183+
184+
if (pe->state != QB_POLL_ENTRY_JOBLIST) {
185+
new_jobs += pe->add_to_jobs(src->l, pe);
186+
}
191187
}
192188

193189
return new_jobs;

0 commit comments

Comments
 (0)