Skip to content

Commit b17de74

Browse files
committed
♻️ Simplify shutdown of socket in #disconnect
This should work both for TCPSocket and for OpenSSL::SSL::SSLSocket. Both will respond to `#to_io` with the TCPSocket.
1 parent e982167 commit b17de74

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

lib/net/imap.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,13 +1139,7 @@ def disconnect
11391139
in_logout_state = try_state_logout?
11401140
return if disconnected?
11411141
begin
1142-
begin
1143-
# try to call SSL::SSLSocket#io.
1144-
@sock.io.shutdown
1145-
rescue NoMethodError
1146-
# @sock is not an SSL::SSLSocket.
1147-
@sock.shutdown
1148-
end
1142+
@sock.to_io.shutdown
11491143
rescue Errno::ENOTCONN
11501144
# ignore `Errno::ENOTCONN: Socket is not connected' on some platforms.
11511145
rescue Exception => e

0 commit comments

Comments
 (0)