ruby-changes:16251
From: shyouhei <ko1@a...>
Date: Tue, 8 Jun 2010 16:50:15 +0900 (JST)
Subject: [ruby-changes:16251] Ruby:r28218 (ruby_1_8_7): merge revision(s) 27688:
shyouhei 2010-06-08 16:50:07 +0900 (Tue, 08 Jun 2010) New Revision: 28218 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28218 Log: merge revision(s) 27688: * lib/net/imap.rb: backported exception handling from trunk. [ruby-core:29745] Modified files: branches/ruby_1_8_7/ChangeLog branches/ruby_1_8_7/lib/net/imap.rb branches/ruby_1_8_7/version.h Index: ruby_1_8_7/ChangeLog =================================================================== --- ruby_1_8_7/ChangeLog (revision 28217) +++ ruby_1_8_7/ChangeLog (revision 28218) @@ -1,3 +1,8 @@ +Tue Jun 8 16:51:48 2010 Shugo Maeda <shugo@r...> + + * lib/net/imap.rb: backported exception handling from trunk. + [ruby-core:29745] + Tue Jun 8 16:42:48 2010 Nobuyoshi Nakada <nobu@r...> * ext/bigdecimal/bigdecimal.c (VpAlloc): ensure buf does not get Index: ruby_1_8_7/version.h =================================================================== --- ruby_1_8_7/version.h (revision 28217) +++ ruby_1_8_7/version.h (revision 28218) @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2010-06-08" #define RUBY_VERSION_CODE 187 #define RUBY_RELEASE_CODE 20100608 -#define RUBY_PATCHLEVEL 282 +#define RUBY_PATCHLEVEL 283 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 Index: ruby_1_8_7/lib/net/imap.rb =================================================================== --- ruby_1_8_7/lib/net/imap.rb (revision 28217) +++ ruby_1_8_7/lib/net/imap.rb (revision 28218) @@ -913,6 +913,7 @@ @continuation_request = nil @logout_command_tag = nil @debug_output_bol = true + @exception = nil @greeting = get_response if @greeting.name == "BYE" @@ -928,14 +929,24 @@ def receive_responses while true + synchronize do + @exception = nil + end begin resp = get_response - rescue Exception - @sock.close - @client_thread.raise($!) + rescue Exception => e + synchronize do + @sock.close unless @sock.closed? + @exception = e + end break end - break unless resp + unless resp + synchronize do + @exception = EOFError.new("end of file reached") + end + break + end begin synchronize do case resp @@ -953,7 +964,9 @@ end if resp.name == "BYE" && @logout_command_tag.nil? @sock.close - raise ByeResponseError, resp.raw_data + @exception = ByeResponseError.new(resp.raw_data) + @response_arrival.broadcast + return end when ContinuationRequest @continuation_request = resp @@ -963,14 +976,21 @@ handler.call(resp) end end - rescue Exception - @client_thread.raise($!) + rescue Exception => e + @exception = e + synchronize do + @response_arrival.broadcast + end end end + synchronize do + @response_arrival.broadcast + end end def get_tagged_response(tag) until @tagged_responses.key?(tag) + raise @exception if @exception @response_arrival.wait end return pick_up_tagged_response(tag) @@ -1103,6 +1123,7 @@ while @continuation_request.nil? && !@tagged_responses.key?(Thread.current[:net_imap_tag]) @response_arrival.wait + raise @exception if @exception end if @continuation_request.nil? pick_up_tagged_response(Thread.current[:net_imap_tag]) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/