Skip to content

Pure ruby backend had very different behaviour to maintain Monitor#readiness #182

Open
@jjyr

Description

@jjyr

Problem

select and poll backend didn't clear monitor#readiness in Selector#select, but ruby 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

use backend ruby
Listening on localhost:1234
server readiness is 
*** ::1:52414 connected
server readiness is r
*** ::1:52414 disconnected
server readiness is 
use backend select
Listening on localhost:1234
server readiness is w
*** ::1:52423 connected
server readiness is r
*** ::1:52423 disconnected
server readiness is r
*** ::1:52424 connected
server readiness is r
*** ::1:52424 disconnected
server readiness is r

Affect

In my case, I save each monitor objects, and use monitor#readable? to detect it status after invokeSelector#select (this method)

Maybe it's not right way to use monitor, but nio4r should maintain the right behaviour and document it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions