diff --git a/lib/async/io/generic.rb b/lib/async/io/generic.rb index 8a20137..a4076f2 100644 --- a/lib/async/io/generic.rb +++ b/lib/async/io/generic.rb @@ -192,6 +192,10 @@ def connected? !@io.closed? end + def readable? + @io.readable? + end + attr_accessor :timeout protected diff --git a/lib/async/io/ssl_socket.rb b/lib/async/io/ssl_socket.rb index bba1840..3659d7a 100644 --- a/lib/async/io/ssl_socket.rb +++ b/lib/async/io/ssl_socket.rb @@ -51,10 +51,14 @@ def initialize(socket, context) super else io = self.class.wrapped_klass.new(socket.to_io, context) - super(io, socket.reactor) - - # We detach the socket from the reactor, otherwise it's possible to add the file descriptor to the selector twice, which is bad. - socket.reactor = nil + if socket.respond_to?(:reactor) + super(io, socket.reactor) + + # We detach the socket from the reactor, otherwise it's possible to add the file descriptor to the selector twice, which is bad. + socket.reactor = nil + else + super(io) + end # This ensures that when the internal IO is closed, it also closes the internal socket: io.sync_close = true