mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/net/imap.rb (disconnect): terminates @receiver_thread even if
@sock.shutdown raises an exception. [ruby-dev:34881] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
81f4dba385
commit
e240f93f21
3 changed files with 49 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
Sun May 9 08:24:24 2010 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* lib/net/imap.rb (disconnect): terminates @receiver_thread even if
|
||||
@sock.shutdown raises an exception. [ruby-dev:34881]
|
||||
|
||||
Sun May 9 06:15:21 2010 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
||||
|
||||
* io.c (nogvl_copy_stream_sendfile): ISO C90 forbids mixed
|
||||
|
|
|
@ -307,9 +307,12 @@ module Net
|
|||
end
|
||||
rescue Errno::ENOTCONN
|
||||
# ignore `Errno::ENOTCONN: Socket is not connected' on some platforms.
|
||||
rescue Exception => e
|
||||
@receiver_thread.raise(e)
|
||||
end
|
||||
@receiver_thread.join
|
||||
@sock.close
|
||||
raise e if e
|
||||
end
|
||||
|
||||
# Returns true if disconnected from the server.
|
||||
|
@ -1012,7 +1015,10 @@ module Net
|
|||
|
||||
@client_thread = Thread.current
|
||||
@receiver_thread = Thread.start {
|
||||
begin
|
||||
receive_responses
|
||||
rescue Exception
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -311,6 +311,43 @@ class IMAPTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_exception_during_shutdown
|
||||
server = TCPServer.new(0)
|
||||
port = server.addr[1]
|
||||
Thread.start do
|
||||
begin
|
||||
sock = server.accept
|
||||
begin
|
||||
sock.print("* OK test server\r\n")
|
||||
sock.gets
|
||||
sock.print("* BYE terminating connection\r\n")
|
||||
sock.print("RUBY0001 OK LOGOUT completed\r\n")
|
||||
ensure
|
||||
sock.close
|
||||
end
|
||||
rescue
|
||||
end
|
||||
end
|
||||
begin
|
||||
begin
|
||||
imap = Net::IMAP.new("localhost", :port => port)
|
||||
imap.instance_eval do
|
||||
def @sock.shutdown(*args)
|
||||
super
|
||||
raise "error"
|
||||
end
|
||||
end
|
||||
imap.logout
|
||||
ensure
|
||||
assert_raise(RuntimeError) do
|
||||
imap.disconnect
|
||||
end
|
||||
end
|
||||
ensure
|
||||
server.close
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def imaps_test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue