diff options
author | Saku Ytti <saku@ytti.fi> | 2014-03-28 11:32:12 +0200 |
---|---|---|
committer | Saku Ytti <saku@ytti.fi> | 2014-03-28 11:32:12 +0200 |
commit | fb8ee99105df5ddacaa47b84f833616f536667ac (patch) | |
tree | e180ae3049d11970590c99dcad9c0915f3da9537 | |
parent | 337ad4715f8aacf5fa15f05c624f2fa18bdad513 (diff) |
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
-rw-r--r-- | lib/oxidized/input/ssh.rb | 12 |
1 files changed, 6 insertions, 6 deletions
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 |