Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop mutex_m dependency #536

Merged
merged 1 commit into from
May 18, 2024
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
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