Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
More compatibility with native sockets.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Apr 23, 2024
1 parent af9164d commit a7c9b65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/async/io/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ def connected?
!@io.closed?
end

def readable?
@io.readable?
end

attr_accessor :timeout

protected
Expand Down
12 changes: 8 additions & 4 deletions lib/async/io/ssl_socket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a7c9b65

Please sign in to comment.