File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -140,8 +140,9 @@ def session(require_session=false)
140
140
141
141
# Returns +true+ if the session has been opened, and the session is currently
142
142
# busy (as defined by Net::SSH::Connection::Session#busy?).
143
+ # Also returns false if the server has failed to connect.
143
144
def busy? ( include_invisible = false )
144
- session && session . busy? ( include_invisible )
145
+ ! failed? && session && session . busy? ( include_invisible )
145
146
end
146
147
147
148
# Closes this server's session. If the session has not yet been opened,
@@ -228,4 +229,4 @@ def postprocess(readers, writers) #:nodoc:
228
229
session . postprocess ( listeners & readers , listeners & writers )
229
230
end
230
231
end
231
- end ; end ; end
232
+ end ; end ; end
Original file line number Diff line number Diff line change @@ -476,7 +476,12 @@ def next_session(server, force=false) #:nodoc:
476
476
return connection
477
477
end
478
478
479
- @open_connections += 1
479
+ # Only increment the open_connections count if the connection
480
+ # is not being forced. Incase of a force, it will already be
481
+ # incremented.
482
+ if !force
483
+ @open_connections += 1
484
+ end
480
485
end
481
486
482
487
begin
@@ -542,6 +547,10 @@ def realize_pending_connections! #:nodoc:
542
547
count = concurrent_connections ? ( concurrent_connections - open_connections ) : @pending_sessions . length
543
548
count . times do
544
549
session = @pending_sessions . pop or break
550
+ # Increment the open_connections count here to prevent
551
+ # creation of connection thread again before that is
552
+ # incremented by the thread.
553
+ @session_mutex . synchronize { @open_connections += 1 }
545
554
@connect_threads << Thread . new do
546
555
session . replace_with ( next_session ( session . server , true ) )
547
556
end
You can’t perform that action at this time.
0 commit comments