diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ebb6cf4..dfe84b3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ appear at the top. ## [Unreleased][] * Your contribution here! + * [#447](https://github.com/capistrano/sshkit/pull/447): Fix broken thread safety by widening critical section - [Takumasa Ochi](https://github.com/aeroastro) ## [1.18.0][] (2018-10-21) diff --git a/lib/sshkit/backends/connection_pool.rb b/lib/sshkit/backends/connection_pool.rb index c7cd4675..37d69eeb 100644 --- a/lib/sshkit/backends/connection_pool.rb +++ b/lib/sshkit/backends/connection_pool.rb @@ -118,9 +118,9 @@ def thread_safe_find_or_create_cache(key) # Update cache key with changed args to prevent cache miss def update_key_if_args_changed(cache, args) new_key = cache_key_for_connection_args(args) - return if cache.same_key?(new_key) caches.synchronize do + return if cache.same_key?(new_key) caches[new_key] = caches.delete(cache.key) cache.key = new_key end