Skip to content
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

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

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

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

HoneyryderChuck opened this issue Dec 7, 2015 · 5 comments
Assignees
Milestone

Comments

@HoneyryderChuck
Copy link

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
Copy link

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
Copy link

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
Copy link
Author

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
Copy link
Author

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
Copy link
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.

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

No branches or pull requests

3 participants