From 70049519cd8ef57b53bb4ffcd8751aceb17eae3b Mon Sep 17 00:00:00 2001 From: shugo Date: Fri, 24 Jul 2009 09:09:04 +0000 Subject: * 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: http://svn.ruby-lang.org/repos/ruby/trunk@24263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/imap.rb | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 574156803..8b7529d79 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 -- cgit