fix poller race condition

One thread may close an fd while another thread is processing the result
events that can include a POLLOUT for the same fd. That same fd might
then get re-opened as another type of object and get added to the poller
again. When the POLLOUT event then gets processed, no `writeable`
function would be present.

This is not a clean fix for the underlying race condition as stray
events might still get processed, but seeing extra stray events should
not be a problem.

Change-Id: I2fa2277bb0ddf512f53917297bd4220fe794dd0e
changes/31/25331/1
Richard Fuchs 6 years ago
parent fb1083f8e3
commit b778b712fc

@ -344,7 +344,9 @@ int poller_poll(struct poller *p, int timeout) {
abort();
mutex_unlock(&p->lock);
it->item.writeable(it->item.fd, it->item.obj, it->item.uintp);
if (it->item.writeable)
it->item.writeable(it->item.fd, it->item.obj, it->item.uintp);
}
else if ((ev->events & POLLIN))
it->item.readable(it->item.fd, it->item.obj, it->item.uintp);

Loading…
Cancel
Save