-
-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pure ruby backend had very different behaviour to maintain Monitor#readiness #182
Comments
Just to confirm I understand the problems:
One option I can think of is to keep a counter inside of I kind of like the latter, because it doesn't make sense to check the readiness of monitors that were not selected by the last |
I'm also prefer latter one, to maintain a counter is not necessary, since Maybe should remove this line, to make pure ruby backend according to libev behaviour. |
@jjyr the reason for the counter is it lets us tell if monitors were selected by the most recent select operation without having to modify any state in the unselected monitors. We could remove that line in selector.rb, but the result would be both backends consistently giving you stale results. I'm not sure exposing stale results is a good idea. |
@jjyr can you please submit a spec/PR. |
Now I think we should not maintain consistency for a wrong use case, we either need a better design to avoid misuse or we just leave it here. |
The counter approach seems simple enough, otherwise I think we can simply document that the readiness state of unselected monitors is undefined behavior that may vary between backends. |
Sounds perfect to me. |
Problem
select
andpoll
backend didn't clear monitor#readiness in Selector#select, butruby
backend did, it set each monitors readiness to nil in Selector#select.https://github.com/socketry/nio4r/blob/master/lib/nio/selector.rb#L87
Reproduce
Run this script to start a modified example/echo_server, then run
telnet localhost 1234
several times.can see different behaviour
Affect
In my case, I save each monitor objects, and use monitor#readable? to detect it status after invoke
Selector#select
(this method)Maybe it's not right way to use monitor, but nio4r should maintain the right behaviour and document it.
The text was updated successfully, but these errors were encountered: