mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/net/imap.rb (receive_responses): does not hang when an unexpected BYE
response received. fixed [ruby-core:27944]. Thanks, Bob Potter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bc885aeae6
commit
69c3348b79
2 changed files with 31 additions and 2 deletions
|
@ -1017,7 +1017,8 @@ module Net
|
|||
end
|
||||
|
||||
def receive_responses
|
||||
while true
|
||||
connection_closed = false
|
||||
until connection_closed
|
||||
synchronize do
|
||||
@exception = nil
|
||||
end
|
||||
|
@ -1054,7 +1055,7 @@ module Net
|
|||
if resp.name == "BYE" && @logout_command_tag.nil?
|
||||
@sock.close
|
||||
@exception = ByeResponseError.new(resp)
|
||||
break
|
||||
connection_closed = true
|
||||
end
|
||||
when ContinuationRequest
|
||||
@continuation_request_arrival.signal
|
||||
|
|
|
@ -279,6 +279,34 @@ class IMAPTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_unexpected_bye
|
||||
server = TCPServer.new(0)
|
||||
port = server.addr[1]
|
||||
Thread.start do
|
||||
begin
|
||||
sock = server.accept
|
||||
begin
|
||||
sock.print("* OK Gimap ready for requests from 75.101.246.151 33if2752585qyk.26\r\n")
|
||||
sock.gets
|
||||
sock.print("* BYE System Error 33if2752585qyk.26\r\n")
|
||||
ensure
|
||||
sock.close
|
||||
end
|
||||
rescue
|
||||
end
|
||||
end
|
||||
begin
|
||||
begin
|
||||
imap = Net::IMAP.new("localhost", :port => port)
|
||||
assert_raise(Net::IMAP::ByeResponseError) do
|
||||
imap.login("user", "password")
|
||||
end
|
||||
end
|
||||
ensure
|
||||
server.close
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def imaps_test
|
||||
|
|
Loading…
Reference in a new issue