* backport r33007 from trunk.

* lib/net/imap.rb (idle): raises a Net::IMAP::Error when the
  connection is closed.  based on the patch by Hugo Barauna.
  [Bug #5190] [ruby-core:38930]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@33008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shugo 2011-08-19 05:18:20 +00:00
parent 31f92d788c
commit f23e93f8b3
3 changed files with 76 additions and 3 deletions

View file

@ -905,10 +905,15 @@ module Net
@idle_done_cond = new_cond
@idle_done_cond.wait
@idle_done_cond = nil
if @receiver_thread_terminating
raise Net::IMAP::Error, "connection closed"
end
ensure
remove_response_handler(response_handler)
put_string("DONE#{CRLF}")
response = get_tagged_response(tag, "IDLE")
unless @receiver_thread_terminating
remove_response_handler(response_handler)
put_string("DONE#{CRLF}")
response = get_tagged_response(tag, "IDLE")
end
end
end
@ -1056,6 +1061,7 @@ module Net
rescue Exception
end
}
@receiver_thread_terminating = false
end
def receive_responses
@ -1115,8 +1121,12 @@ module Net
end
end
synchronize do
@receiver_thread_terminating = true
@tagged_response_arrival.broadcast
@continuation_request_arrival.broadcast
if @idle_done_cond
@idle_done_cond.signal
end
end
end