From a8e4a2aa175b0650c0793c2fa64d574b5e8f188e Mon Sep 17 00:00:00 2001 From: yugui Date: Sun, 23 May 2010 12:18:20 +0000 Subject: merges r27690 and r27903 from trunk into ruby_1_9_2. -- * lib/net/imap.rb (disconnect): terminates @receiver_thread even if @sock.shutdown raises an exception. [ruby-dev:34881] -- * lib/net/imap.rb (disconnect): closes the socket of a Net::IMAP object only when it is not closed. [ruby-dev:41350] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@27971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/imap.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3