Skip to content

Commit 4edb96f

Browse files
committed
Fix default options and updating key
:password_prompt and :logger options are added in net-ssh `Net::SSH.assign_defaults`. Set default options early for ConnectionPool cache key. The key in Cache object should be updated for comparing next time.
1 parent 264e980 commit 4edb96f

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

lib/sshkit/backends/connection_pool.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def update_key_if_args_changed(cache, args)
122122

123123
caches.synchronize do
124124
caches[new_key] = caches.delete(cache.key)
125+
cache.key = new_key
125126
end
126127
end
127128

lib/sshkit/backends/connection_pool/cache.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# A Cache holds connections for a given key. Each connection is stored along
22
# with an expiration time so that its idle duration can be measured.
33
class SSHKit::Backend::ConnectionPool::Cache
4-
attr_reader :key
4+
attr_accessor :key
55

66
def initialize(key, idle_timeout, closer)
77
@key = key

lib/sshkit/backends/netssh.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,20 @@ def ssh_options
3636
if Net::SSH::VALID_OPTIONS.include?(:known_hosts)
3737
def default_options
3838
@default_options ||= {known_hosts: SSHKit::Backend::Netssh::KnownHosts.new}
39+
assign_defaults
3940
end
4041
else
4142
def default_options
4243
@default_options ||= {}
44+
assign_defaults
4345
end
4446
end
47+
48+
# Set default options early for ConnectionPool cache key
49+
def assign_defaults
50+
Net::SSH.assign_defaults(@default_options)
51+
@default_options
52+
end
4553
end
4654

4755
def upload!(local, remote, options = {})

0 commit comments

Comments
 (0)