Having Problems With Celluloid::IO / Nonblocking IO #3520

Closed
HoneyryderChuck opened this Issue Dec 7, 2015 · 5 comments

Comments

Projects
None yet
3 participants
@HoneyryderChuck

Coming from celluloid/celluloid-io#156. Maybe someone reported this already, couldn't find the specific one, but I saw a lot of non-blocking IO related issues.

@tarcieri

This comment has been minimized.

Show comment
Hide comment
@tarcieri

tarcieri Dec 7, 2015

For context, this is the error:

SocketError: (IO::EAGAINWaitReadable) recvfrom(2) would block
    org/jruby/ext/socket/RubyUDPSocket.java:220:in `recvfrom_nonblock'
    org/jruby/ext/socket/RubyUDPSocket.java:227:in `recvfrom_nonblock'
    /install/path/gems/celluloid-io-0.17.2/lib/celluloid/io/udp_socket.rb:22:in `recvfrom'
    /install/path/gems/celluloid-io-0.17.2/lib/celluloid/io/dns_resolver.rb:45:in `resolve'
    /install/path/gems/celluloid-io-0.17.2/lib/celluloid/io/tcp_socket.rb:63:in `initialize'

Expected: IO::EAGAINWaitReadable (or at least a class with IO::WaitReadable as an ancestor)
Actual: SocketError (with odd "IO::EAGAINWaitReadable" parenthetical)

tarcieri commented Dec 7, 2015

For context, this is the error:

SocketError: (IO::EAGAINWaitReadable) recvfrom(2) would block
    org/jruby/ext/socket/RubyUDPSocket.java:220:in `recvfrom_nonblock'
    org/jruby/ext/socket/RubyUDPSocket.java:227:in `recvfrom_nonblock'
    /install/path/gems/celluloid-io-0.17.2/lib/celluloid/io/udp_socket.rb:22:in `recvfrom'
    /install/path/gems/celluloid-io-0.17.2/lib/celluloid/io/dns_resolver.rb:45:in `resolve'
    /install/path/gems/celluloid-io-0.17.2/lib/celluloid/io/tcp_socket.rb:63:in `initialize'

Expected: IO::EAGAINWaitReadable (or at least a class with IO::WaitReadable as an ancestor)
Actual: SocketError (with odd "IO::EAGAINWaitReadable" parenthetical)

@tarcieri

This comment has been minimized.

Show comment
Hide comment
@tarcieri

tarcieri Dec 7, 2015

Here's the code in question:

https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/ext/socket/RubyUDPSocket.java#L220

It looks like it's throwing the wrong exception (SocketError) in this case (instead of IO::EAGAINWaitReadable)?

tarcieri commented Dec 7, 2015

Here's the code in question:

https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/ext/socket/RubyUDPSocket.java#L220

It looks like it's throwing the wrong exception (SocketError) in this case (instead of IO::EAGAINWaitReadable)?

@HoneyryderChuck

This comment has been minimized.

Show comment
Hide comment
@HoneyryderChuck

HoneyryderChuck Dec 8, 2015

It's actually throwing SocketError in other places where it shouldn't:

# ruby 2.0.0
> UDPSocket.new.bind "127.0.0.1", 191 #=> Errno::EACCES: Permission denied - bind(2)
# jruby 9.0.4.0
> UDPSocket.new.bind "127.0.0.1", 191 #=> SocketError: bind: name or service not known
from org/jruby/ext/socket/RubyUDPSocket.java:157:in `bind'

It's actually throwing SocketError in other places where it shouldn't:

# ruby 2.0.0
> UDPSocket.new.bind "127.0.0.1", 191 #=> Errno::EACCES: Permission denied - bind(2)
# jruby 9.0.4.0
> UDPSocket.new.bind "127.0.0.1", 191 #=> SocketError: bind: name or service not known
from org/jruby/ext/socket/RubyUDPSocket.java:157:in `bind'
@HoneyryderChuck

This comment has been minimized.

Show comment
Hide comment
@HoneyryderChuck

HoneyryderChuck Dec 8, 2015

I also think that this is an overall socket handling issue (not only udp):

# ruby 2.0.0
> u = TCPSocket.new "127.0.0.1", 22
> u.read_nonblock 22 #=> "Open bla bla"
> u.read_nonblock 22 #=> Errno::EAGAIN: Resource temporarily unavailable - read would block
# jruby 9.0.4.0
> u = TCPSocket.new "127.0.0.1", 22
> u.read_nonblock 22 #=> "Open bla bla"
> u.read_nonblock 22 #=> IO::EAGAINWaitReadable: Resource temporarily unavailable - read would block
from org/jruby/RubyIO.java:2767:in `read_nonblock'

I also think that this is an overall socket handling issue (not only udp):

# ruby 2.0.0
> u = TCPSocket.new "127.0.0.1", 22
> u.read_nonblock 22 #=> "Open bla bla"
> u.read_nonblock 22 #=> Errno::EAGAIN: Resource temporarily unavailable - read would block
# jruby 9.0.4.0
> u = TCPSocket.new "127.0.0.1", 22
> u.read_nonblock 22 #=> "Open bla bla"
> u.read_nonblock 22 #=> IO::EAGAINWaitReadable: Resource temporarily unavailable - read would block
from org/jruby/RubyIO.java:2767:in `read_nonblock'

kares added a commit to kares/jruby that referenced this issue Dec 20, 2015

@kares kares self-assigned this Dec 20, 2015

@kares

This comment has been minimized.

Show comment
Hide comment
@kares

kares Dec 23, 2015

Member

3cadb0c handles the main issue and there's some more tunings: bdcc08e, 7545673 and 4f9e6be. note that some of MRI's error is not followed blindly e.g. TCPSocket.new 7545673#diff-f433d6e3a0314b6d0e9bcf7669f745aaR147 (error type changes when port is too big vs. negative) ... but that should not matter much. let us know if there's anything not behaving sufficiently for Celluloid::IO.

Member

kares commented Dec 23, 2015

3cadb0c handles the main issue and there's some more tunings: bdcc08e, 7545673 and 4f9e6be. note that some of MRI's error is not followed blindly e.g. TCPSocket.new 7545673#diff-f433d6e3a0314b6d0e9bcf7669f745aaR147 (error type changes when port is too big vs. negative) ... but that should not matter much. let us know if there's anything not behaving sufficiently for Celluloid::IO.

@kares kares closed this Dec 23, 2015

@kares kares added this to the JRuby 9.0.5.0 milestone Dec 23, 2015

@LukasReschke LukasReschke referenced this issue in michenriksen/aquatone Jun 19, 2017

Closed

uninitialized constant IO::EAGAINWaitReadable #4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment