diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-24 09:09:04 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-24 09:09:04 +0000 |
commit | 9914a16ca941f47b9fa32874933594a59cf65267 (patch) | |
tree | 9d0e81ef4f915e2f9dab87583bce94e7474eb342 /lib/net/imap.rb | |
parent | bdd52721b3fc5cfeb0602f7127ade39afa759a3e (diff) |
* lib/net/imap.rb (idle): leaves IDLE in a ensure clause. a patch
from Eric Hodel.
* test/net/imap/test_imap.rb (setup, teardown): turn on
Socket.do_not_reverse_lookup in tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net/imap.rb')
-rw-r--r-- | lib/net/imap.rb | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 5741568034..8b7529d79d 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -851,13 +851,16 @@ module Net tag = Thread.current[:net_imap_tag] = generate_tag put_string("#{tag} IDLE#{CRLF}") - add_response_handler(response_handler) - @idle_done_cond = new_cond - @idle_done_cond.wait - @idle_done_cond = nil - remove_response_handler(response_handler) - put_string("DONE#{CRLF}") - response = get_tagged_response(tag, "IDLE") + begin + add_response_handler(response_handler) + @idle_done_cond = new_cond + @idle_done_cond.wait + @idle_done_cond = nil + ensure + remove_response_handler(response_handler) + put_string("DONE#{CRLF}") + response = get_tagged_response(tag, "IDLE") + end end return response @@ -865,10 +868,10 @@ module Net # Leaves IDLE. def idle_done - if @idle_done_cond.nil? - raise Net::IMAP::Error, "not during IDLE" - end synchronize do + if @idle_done_cond.nil? + raise Net::IMAP::Error, "not during IDLE" + end @idle_done_cond.signal end end @@ -985,6 +988,7 @@ module Net @response_handlers = [] @tagged_response_arrival = new_cond @continuation_request_arrival = new_cond + @idle_done_cond = nil @logout_command_tag = nil @debug_output_bol = true @exception = nil |