diff options
Diffstat (limited to 'lib/net/imap.rb')
-rw-r--r-- | lib/net/imap.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 46e8f201a1..3404700297 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -307,9 +307,16 @@ module Net end rescue Errno::ENOTCONN # ignore `Errno::ENOTCONN: Socket is not connected' on some platforms. + rescue Exception => e + @receiver_thread.raise(e) end @receiver_thread.join - @sock.close + synchronize do + unless @sock.closed? + @sock.close + end + end + raise e if e end # Returns true if disconnected from the server. @@ -1012,7 +1019,10 @@ module Net @client_thread = Thread.current @receiver_thread = Thread.start { - receive_responses + begin + receive_responses + rescue Exception + end } end |