diff options
author | Matthew Draper <matthew@trebex.net> | 2017-04-15 00:05:35 +0930 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2017-04-26 12:32:53 -0700 |
commit | ce2abffc0e29f562da26f89d7f07aeaf06a9cbcd (patch) | |
tree | ad69c2a4b923e2d988845a31866b9ab220921206 /activerecord/lib/active_record | |
parent | b6ac50b3ee2ff51203774cc0c2647a437237f396 (diff) | |
download | rails-ce2abffc0e29f562da26f89d7f07aeaf06a9cbcd.tar.gz rails-ce2abffc0e29f562da26f89d7f07aeaf06a9cbcd.tar.bz2 rails-ce2abffc0e29f562da26f89d7f07aeaf06a9cbcd.zip |
Lock connection before checking it in
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb index 177b253645..61bf5477aa 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -506,14 +506,16 @@ module ActiveRecord # +conn+: an AbstractAdapter object, which was obtained by earlier by # calling #checkout on this pool. def checkin(conn) - synchronize do - remove_connection_from_thread_cache conn + conn.lock.synchronize do + synchronize do + remove_connection_from_thread_cache conn - conn._run_checkin_callbacks do - conn.expire - end + conn._run_checkin_callbacks do + conn.expire + end - @available.add conn + @available.add conn + end end end |