dpc / mioco.pre-0.9

Scalable, coroutine-based, asynchronous IO handling library for Rust programming language. (aka MIO COroutines).
Mozilla Public License 2.0
457 stars 30 forks source link

Protect against spurious events. #10

Closed dpc closed 9 years ago

dpc commented 9 years ago

mio can generate spurious events due to: https://github.com/carllerche/mio/issues/219 .

Spurious events can mess with select() semantics. After coroutine is resumed after select(), the Event Source that was returned must not block on a next corresponding operation. If the waking event was a spurious one, the whole coroutine could block on something that might not even happen again.

dpc commented 9 years ago

Current idea: after mio introduces tick(), mioco::Server, should keep a "tick" counter, and pass it to EventSource::ready(), Coroutine should remember the tick counter on the last reregister and skip all EventSources::ready() that had the tick the same as the last saved one. Note: the event source still needs to be reregistered, even if ignored.

dpc commented 9 years ago

Another, probably saner approach, would be to change select() semantics and thus make the spurious wakeups harmless. If split between select() and following blocking operation could be removed without hindering the API usability, it would help a lot. The biggest problem here is that select can be called on a set of non-uniform event sources.

dpc commented 9 years ago

https://github.com/carllerche/mio/pull/231 has landed. We can remove workaround tick += 1 and put it in proper place.

dpc commented 9 years ago

Implemented in f747377e