diff --git a/lib/sshkit/backends/netssh.rb b/lib/sshkit/backends/netssh.rb index 7211c7c9..03be64cb 100644 --- a/lib/sshkit/backends/netssh.rb +++ b/lib/sshkit/backends/netssh.rb @@ -1,6 +1,5 @@ require 'English' require 'strscan' -require 'mutex_m' require 'net/ssh' module Net diff --git a/lib/sshkit/backends/netssh/known_hosts.rb b/lib/sshkit/backends/netssh/known_hosts.rb index 869d406a..bb4ee8ac 100644 --- a/lib/sshkit/backends/netssh/known_hosts.rb +++ b/lib/sshkit/backends/netssh/known_hosts.rb @@ -7,12 +7,11 @@ module Backend class Netssh < Abstract class KnownHostsKeys - include Mutex_m - def initialize(path) super() @path = File.expand_path(path) @hosts_keys = nil + @mutex = Mutex.new end def keys_for(hostlist) @@ -46,7 +45,7 @@ def sha1 end def parse_file - synchronize do + @mutex.synchronize do return if hosts_keys && hosts_hashes unless File.readable?(path) @@ -112,11 +111,10 @@ def parse_key(scanner) end class KnownHosts - include Mutex_m - def initialize super() @files = {} + @mutex = Mutex.new end def search_for(host, options = {}) @@ -128,13 +126,13 @@ def search_for(host, options = {}) def add(*args) ::Net::SSH::KnownHosts.add(*args) - synchronize { @files = {} } + @mutex.synchronize { @files = {} } end private def known_hosts_file(path) - @files[path] || synchronize { @files[path] ||= KnownHostsKeys.new(path) } + @files[path] || @mutex.synchronize { @files[path] ||= KnownHostsKeys.new(path) } end end diff --git a/sshkit.gemspec b/sshkit.gemspec index 1584bcfe..416ccb18 100644 --- a/sshkit.gemspec +++ b/sshkit.gemspec @@ -21,7 +21,6 @@ Gem::Specification.new do |gem| gem.version = SSHKit::VERSION gem.add_runtime_dependency('base64') if RUBY_VERSION >= "2.4" - gem.add_runtime_dependency('mutex_m') gem.add_runtime_dependency('net-ssh', '>= 2.8.0') gem.add_runtime_dependency('net-scp', '>= 1.1.2') gem.add_runtime_dependency('net-sftp', '>= 2.1.2')