From fb8ee99105df5ddacaa47b84f833616f536667ac Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Fri, 28 Mar 2014 11:32:12 +0200 Subject: if disconnect_cli does not disconnect us, give up If we stay connected on the device (model broken?) give up after timeout, instead of sitting in the model forever --- lib/oxidized/input/ssh.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/input/ssh.rb b/lib/oxidized/input/ssh.rb index ef15292..a858213 100644 --- a/lib/oxidized/input/ssh.rb +++ b/lib/oxidized/input/ssh.rb @@ -50,12 +50,12 @@ module Oxidized private def disconnect - begin - disconnect_cli - @ssh.loop - @ssh.close if not @ssh.closed? - rescue Errno::ECONNRESET, Net::SSH::Disconnect, IOError - end + disconnect_cli + # if disconnect does not disconnect us, give up after timeout + Timeout::timeout(CFG.timeout) { @ssh.loop } + rescue Errno::ECONNRESET, Net::SSH::Disconnect, IOError + ensure + @ssh.close if not @ssh.closed? end def shell_open ssh -- cgit v1.2.1