diff options
| author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-21 17:47:33 +0000 |
|---|---|---|
| committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-21 17:47:33 +0000 |
| commit | d6a35b40de168a4bc74a51ddbb021b9a5327b3ee (patch) | |
| tree | c8048089063c91365f301e7ebd0aa3a4b0cfa6e3 /lib/net | |
| parent | c9d1ebcf837dc049c913ecc7cfc4e6c3d8337c81 (diff) | |
| download | ruby-d6a35b40de168a4bc74a51ddbb021b9a5327b3ee.tar.gz ruby-d6a35b40de168a4bc74a51ddbb021b9a5327b3ee.tar.xz ruby-d6a35b40de168a4bc74a51ddbb021b9a5327b3ee.zip | |
* lib/net/imap.rb: do not use Thread#raise. [ruby-dev:34739]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net')
| -rw-r--r-- | lib/net/imap.rb | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 016f567b0..ce765b0a3 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -936,6 +936,7 @@ module Net @continuation_request_arrival = new_cond @logout_command_tag = nil @debug_output_bol = true + @exception = nil @greeting = get_response if @greeting.name == "BYE" @@ -951,14 +952,24 @@ module Net 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 + @exception = e + end + break + end + unless resp + synchronize do + @exception = EOFError.new("end of file reached") + end break end - break unless resp begin synchronize do case resp @@ -976,7 +987,8 @@ module Net end if resp.name == "BYE" && @logout_command_tag.nil? @sock.close - raise ByeResponseError, resp.raw_data + @exception = ByeResponseError.new(resp.raw_data) + break end when ContinuationRequest @continuation_request_arrival.signal @@ -985,14 +997,23 @@ module Net handler.call(resp) end end - rescue Exception - @client_thread.raise($!) + rescue Exception => e + @exception = e + synchronize do + @tagged_response_arrival.broadcast + @continuation_request_arrival.broadcast + end end end + synchronize do + @tagged_response_arrival.broadcast + @continuation_request_arrival.broadcast + end end def get_tagged_response(tag, cmd) until @tagged_responses.key?(tag) + raise @exception if @exception @tagged_response_arrival.wait end resp = @tagged_responses.delete(tag) @@ -1119,6 +1140,7 @@ module Net def send_literal(str) put_string("{" + str.length.to_s + "}" + CRLF) @continuation_request_arrival.wait + raise @exception if @exception put_string(str) end |
