summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason DeTiberus <jdetiber@redhat.com>2014-12-18 10:00:16 -0500
committerJason DeTiberus <jdetiber@redhat.com>2014-12-18 21:55:25 -0500
commitb1ea851241ed041c8a34b671852bca4374f5c0a4 (patch)
tree4bf1701e2ecdf5d8f8b476e7b7ba7e1fb6f8afbe
parent00490d67008b2528e9be30cb14c097fdc30d2c9d (diff)
downloadnet-ssh-b1ea851241ed041c8a34b671852bca4374f5c0a4.tar.gz
Keepalive fixes
- Replaced put statement with debug - Added include for Loggable - Reset @unresponded_keepalive_count before raising Net::SSH::Timeout - When passing Net::SSH.start a block, the ensure statement calls connection.close, if the connection is restored at this point, the close call will still fail since the unresponded_keepalive_count > 0
-rw-r--r--lib/net/ssh/connection/keepalive.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/net/ssh/connection/keepalive.rb b/lib/net/ssh/connection/keepalive.rb
index 7ebccb1..c66a9db 100644
--- a/lib/net/ssh/connection/keepalive.rb
+++ b/lib/net/ssh/connection/keepalive.rb
@@ -1,6 +1,10 @@
+require 'net/ssh/loggable'
+
module Net; module SSH; module Connection
module Keepalive
+ include Loggable
+
# Default IO.select timeout threshold
DEFAULT_IO_SELECT_TIMEOUT = 300
@@ -34,15 +38,16 @@ module Keepalive
@unresponded_keepalive_count += 1
send_global_request("keepalive@openssh.com") { |success, response|
- puts "before zero => #{@unresponded_keepalive_count}"
+ debug { "keepalive response successful. Missed #{@unresponded_keepalive_count-1} keepalives" }
@unresponded_keepalive_count = 0
}
@last_keepalive_sent_at = Time.now
if keepalive_maxcount > 0 && @unresponded_keepalive_count > keepalive_maxcount
error { "Timeout, server #{host} not responding. Missed #{@unresponded_keepalive_count-1} timeouts." }
+ @unresponded_keepalive_count = 0
raise Net::SSH::Timeout, "Timeout, server #{host} not responding."
end
end
end
-end; end; end \ No newline at end of file
+end; end; end