lib/net/ssh/multi/session.rb in net-ssh-multi-1.2.1 vs lib/net/ssh/multi/session.rb in net-ssh-multi-1.3.0.rc1

- old
+ new

@@ -423,11 +423,11 @@ # "wait forever". If the block is given, then it will be used to determine # whether #process returns +true+ (the block did not return +false+), or # +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) readers = server_list.map { |s| s.readers }.flatten writers = server_list.map { |s| s.writers }.flatten @@ -437,9 +437,18 @@ if readers return postprocess(readers, writers) else return true 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.