Skip to content

Commit

Permalink
Merge pull request #447 from aeroastro/feature/fix-race-condition
Browse files Browse the repository at this point in the history
Fix broken thread safety by widening critical section on ConnectionPool
  • Loading branch information
leehambley authored Jan 19, 2019
2 parents 749337b + 918cfd8 commit 702f193
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion lib/sshkit/backends/connection_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 702f193

Please sign in to comment.