Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

Adding support for io/wait and wait_readable/writable API, which matc… #170

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

HoneyryderChuck
Copy link

…hes the Celluloid IO Socket APIs, excepted for the signature; Added support for timeout parameter, which will bubble down to Celluloid.timeout; falling back to Kernel.select when the io does not define the method (SSLSockets) or when the implementation in the ruby VMs is buggy (TCPServer and UNIXServer#wait_readable/writable are throwing Errno::EINVAL, weird)

…hes the Celluloid IO Socket APIs, excepted for the signature; Added support for timeout parameter, which will bubble down to Celluloid.timeout; falling back to Kernel.select when the io does not define the method (SSLSockets) or when the implementation in the ruby VMs is buggy (TCPServer and UNIXServer#wait_readable/writable are throwing Errno::EINVAL, weird)
io = io.to_io
if IO.evented?
mailbox = Thread.current[:celluloid_mailbox]
mailbox.reactor.wait_readable(io)
mailbox.reactor.wait_readable(io, timeout=nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err, this sets the timeout to nil always...

@tarcieri
Copy link
Member

This could probably use some specs...

@HoneyryderChuck
Copy link
Author

@tarcieri I didn't want to write any specs before clearing the awful bit of code inside the reactor. I really think it's time someone takes a look at celluloid/celluloid#491 , code could be cleaned up after that.

@tarcieri
Copy link
Member

I didn't want to write any specs before clearing the awful bit of code inside the reactor.

Why? You are trying to reimplement core Ruby behavior which is completely orthogonal to the reactor.

I mentioned specs specifically because your code has obvious bugs in it (timeout = nil as a parameter to a method invocation)

@HoneyryderChuck
Copy link
Author

@tarcieri maybe I expressed myself in a wrong way. Specs will come. This pull request is far from over. The main goal of it (and this should have been stated in the main description) is to add celluloid-io-compatible reimplementations of the io/wait methods, of which wait_readable and wait_writable are only two. I want to get the specs sorted out, but I wanted to discuss this here, which looks rather ugly because Celluloid.timeout is still a private method. That pull request I linked (which is quite old) not only fixes that, but also provides a Timeout.timeout compatible signature, something that has been hindering proper support for some core network libraries.

Since this is a different topic, we can discuss it there. I'll continue the io/wait part on this side.

Tiago Cardoso added 9 commits January 19, 2016 14:01
…ve been a higuer timeout or a timeout on the wait event; the latter is identified by the timeout parameter being passed or not, and therefore can nullify the timeout error caught; otherwise, timeout bubbles up
…lso trying to adhere to the convention; a successful wait_* call returns the socket; it returns nil otherwise
@tarcieri
Copy link
Member

@TiagoCardoso1983 sounds good, I definitely would like to have io/wait compatibility

@HoneyryderChuck
Copy link
Author

@tarcieri FYI ruby/net-telnet#3

Tiago Cardoso added 2 commits January 20, 2016 16:35
@HoneyryderChuck
Copy link
Author

@tarcieri missing API was added, whenever you have some time for a review.

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

Successfully merging this pull request may close these issues.

2 participants