Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/net/ssh/multi/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ def session(require_session=false)

# Returns +true+ if the session has been opened, and the session is currently
# busy (as defined by Net::SSH::Connection::Session#busy?).
# Also returns false if the server has failed to connect.
def busy?(include_invisible=false)
session && session.busy?(include_invisible)
!failed? && session && session.busy?(include_invisible)
end

# Closes this server's session. If the session has not yet been opened,
Expand Down Expand Up @@ -228,4 +229,4 @@ def postprocess(readers, writers) #:nodoc:
session.postprocess(listeners & readers, listeners & writers)
end
end
end; end; end
end; end; end
11 changes: 10 additions & 1 deletion lib/net/ssh/multi/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,12 @@ def next_session(server, force=false) #:nodoc:
return connection
end

@open_connections += 1
# Only increment the open_connections count if the connection
# is not being forced. Incase of a force, it will already be
# incremented.
if !force
@open_connections += 1
end
end

begin
Expand Down Expand Up @@ -542,6 +547,10 @@ def realize_pending_connections! #:nodoc:
count = concurrent_connections ? (concurrent_connections - open_connections) : @pending_sessions.length
count.times do
session = @pending_sessions.pop or break
# Increment the open_connections count here to prevent
# creation of connection thread again before that is
# incremented by the thread.
@session_mutex.synchronize { @open_connections += 1 }
@connect_threads << Thread.new do
session.replace_with(next_session(session.server, true))
end
Expand Down