summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/net/ssh/multi/pending_connection.rb22
-rw-r--r--lib/net/ssh/multi/server.rb2
-rw-r--r--lib/net/ssh/multi/session.rb11
-rw-r--r--lib/net/ssh/multi/session_actions.rb4
-rw-r--r--lib/net/ssh/multi/version.rb10
5 files changed, 43 insertions, 6 deletions
diff --git a/lib/net/ssh/multi/pending_connection.rb b/lib/net/ssh/multi/pending_connection.rb
index 6af0fac..5faaf70 100644
--- a/lib/net/ssh/multi/pending_connection.rb
+++ b/lib/net/ssh/multi/pending_connection.rb
@@ -31,6 +31,28 @@ module Net; module SSH; module Multi
end
end
+ # Represents a #forward action.
+ class ForwardRecording
+ def initialize
+ @recordings = []
+ end
+
+ def remote(port, host, remote_port, remote_host="127.0.0.1")
+ @recordings << [:remote, port, host, remote_port, remote_host]
+ end
+
+ def replay_on(session)
+ forward = session.forward
+ @recordings.each { |args| forward.send(*args) }
+ end
+ end
+
+ def forward
+ forward = ForwardRecording.new
+ @recordings << forward
+ forward
+ end
+
# Represents a #send_global_request action.
class SendGlobalRequestRecording #:nodoc:
attr_reader :type, :extra, :callback
diff --git a/lib/net/ssh/multi/server.rb b/lib/net/ssh/multi/server.rb
index 77c5948..bcf3678 100644
--- a/lib/net/ssh/multi/server.rb
+++ b/lib/net/ssh/multi/server.rb
@@ -1,4 +1,5 @@
require 'net/ssh'
+require 'timeout'
module Net; module SSH; module Multi
# Encapsulates the connection information for a single remote server, as well
@@ -55,6 +56,7 @@ module Net; module SSH; module Multi
@gateway = @options.delete(:via)
@failed = false
+ @session = @ready_session = nil
end
# Returns the value of the server property with the given +key+. Server
diff --git a/lib/net/ssh/multi/session.rb b/lib/net/ssh/multi/session.rb
index 2e2468f..409aeae 100644
--- a/lib/net/ssh/multi/session.rb
+++ b/lib/net/ssh/multi/session.rb
@@ -425,7 +425,7 @@ module Net; module SSH; module Multi
# +false+ (the block returned +false+).
def process(wait=nil, &block)
realize_pending_connections!
- wait = @connect_threads.any? ? 0 : wait
+ wait = @connect_threads.any? ? 0 : io_select_wait(wait)
return false unless preprocess(&block)
@@ -441,6 +441,15 @@ module Net; module SSH; module Multi
end
end
+ def io_select_wait(wait)
+ [wait, keepalive_interval].compact.min
+ end
+
+ def keepalive_interval
+ servers = server_list.select { |s| s.options[:keepalive] }
+ servers.map { |s| s.options[:keepalive_interval] }.compact.min
+ end
+
# Runs the preprocess stage on all servers. Returns false if the block
# returns false, and true if there either is no block, or it returns true.
# This is called as part of the #process method.
diff --git a/lib/net/ssh/multi/session_actions.rb b/lib/net/ssh/multi/session_actions.rb
index 2d87392..c6b1355 100644
--- a/lib/net/ssh/multi/session_actions.rb
+++ b/lib/net/ssh/multi/session_actions.rb
@@ -118,8 +118,8 @@ module Net; module SSH; module Multi
# end
def exec(command, &block)
open_channel do |channel|
- channel.exec(command) do |ch, success|
- raise "could not execute command: #{command.inspect} (#{ch[:host]})" unless success
+ channel.exec(command) do |c, success|
+ raise "could not execute command: #{command.inspect} (#{c[:host]})" unless success
channel.on_data do |ch, data|
if block
diff --git a/lib/net/ssh/multi/version.rb b/lib/net/ssh/multi/version.rb
index 9854f32..c2f085e 100644
--- a/lib/net/ssh/multi/version.rb
+++ b/lib/net/ssh/multi/version.rb
@@ -7,13 +7,17 @@ module Net; module SSH; module Multi
MAJOR = 1
# The minor component of the library's version
- MINOR = 2
+ MINOR = 3
# The tiny component of the library's version
- TINY = 1
+ TINY = 0
+
+ # The prerelease component of this version of the Net::SSH library
+ # nil allowed
+ PRE = "rc1"
# The library's version as a Version instance
- CURRENT = new(MAJOR, MINOR, TINY)
+ CURRENT = new(*[MAJOR, MINOR, TINY, PRE].compact)
# The library's version as a String instance
STRING = CURRENT.to_s