socketry / io-event

MIT License
66 stars 15 forks source link

Fix Select selector backend per-IO waiter queue handling #63

Closed Math2 closed 1 year ago

Math2 commented 1 year ago

When multiple fibers wait on different events for the same IO object and only a subset of the polled events happen, some of the fibers could be woken up prematurely (with a subset of the events they asked for) and dropped from the queue.

Fix by re-inserting the waiters into the IO object's queue when none of their events were triggered.

Types of Changes

Contribution

I tried to modify the existing code as little as possible to fix this, but it's really starting to make the per-IO queue handling way more complicated than it should be...

ioquatix commented 1 year ago

This looks good to me. Thanks for including a test. I'll think about the queue implementation.

ioquatix commented 1 year ago

Thanks for this, I'm going to merge it as it fixes the issue, but I might re-evaluate how the IO wait queue is handled.