fix(ei): Drain all events sitting in our pipe
If we're starved for resources, we may end up with more than 64 notifications in our pipe before we get to actually read them. Those notifications are just that though, so let's drain them.
This commit is contained in:
committed by
Nick Bolton
parent
59df2db7b7
commit
00f53c1aac
@ -81,8 +81,12 @@ void EiEventQueueBuffer::waitForEvent(double timeout_in_ms)
|
||||
// and potentially testCancel
|
||||
if (pfds[PIPEFD].revents & POLLIN) {
|
||||
char buf[64];
|
||||
auto result = read(pipe_r_, buf, sizeof(buf)); // discard
|
||||
LOG_DEBUG2("event queue read result: %d", result);
|
||||
ssize_t total = 0;
|
||||
ssize_t result;
|
||||
while ((result = read(pipe_r_, buf, sizeof(buf)) > 0)) {
|
||||
total += result;
|
||||
}
|
||||
LOG_DEBUG2("event queue read result: %d (total drained: %zd)", result, total);
|
||||
}
|
||||
}
|
||||
Thread::testCancel();
|
||||
|
||||
Reference in New Issue
Block a user