Skip to content

Commit

Permalink
Drop mutex_m dependency (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
Earlopain authored May 18, 2024
1 parent 286e93a commit 830751c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
1 change: 0 additions & 1 deletion lib/sshkit/backends/netssh.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'English'
require 'strscan'
require 'mutex_m'
require 'net/ssh'

module Net
Expand Down
12 changes: 5 additions & 7 deletions lib/sshkit/backends/netssh/known_hosts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 = {})
Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion sshkit.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 830751c

Please sign in to comment.