1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Issue #441, when asked to teardown the connection to a server, if the connection is already dead recent Net::SSH versions will throw Net::SSH::Disconnected so handle that too

This commit is contained in:
Will Bryant 2013-04-21 20:13:07 +12:00
parent 0800ee5087
commit e148a8edab
2 changed files with 19 additions and 1 deletions

View file

@ -141,7 +141,7 @@ module Capistrano
begin
session = sessions.delete(server)
session.close if session
rescue IOError
rescue IOError, Net::SSH::Disconnect
# the TCP connection is already dead
end
end

View file

@ -398,6 +398,24 @@ class ConfigurationConnectionsTest < Test::Unit::TestCase
@config.execute_on_servers {}
end
def test_execute_on_servers_should_cope_with_already_disconnected_connections_when_attempting_to_close_them
cap1 = server("cap1")
cap2 = server("cap2")
connection1 = mock()
connection2 = mock()
connection3 = mock()
connection4 = mock()
connection1.expects(:close).raises(Net::SSH::Disconnect)
connection2.expects(:close)
connection3.expects(:close)
connection4.expects(:close)
@config.current_task = mock_task(:max_hosts => 1)
@config.expects(:find_servers_for_task).times(2).with(@config.current_task, {}).returns([cap1, cap2])
Capistrano::SSH.expects(:connect).times(4).returns(connection1).then.returns(connection2).then.returns(connection3).then.returns(connection4)
@config.execute_on_servers {}
@config.execute_on_servers {}
end
def test_connect_should_honor_once_option
assert @config.sessions.empty?
@config.current_task = mock_task