diff options
author | Michael Koziarski <michael@koziarski.com> | 2007-10-25 08:09:41 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2007-10-25 08:09:41 +0000 |
commit | 11d2a309c5f67c74332b285bf07c98cda6b6ecb1 (patch) | |
tree | fa9233f9612e96852364b7ec29304beaac8fb657 | |
parent | 192e463d058f07c878534c23cf7da5a66a27eb8d (diff) | |
download | rails-11d2a309c5f67c74332b285bf07c98cda6b6ecb1.tar.gz rails-11d2a309c5f67c74332b285bf07c98cda6b6ecb1.tar.bz2 rails-11d2a309c5f67c74332b285bf07c98cda6b6ecb1.zip |
Make clear_reloadable_connections! take account of @@allow_concurrency. Closes #7579 [wilson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8014 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb index aa9e133fe4..801cb23362 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb @@ -89,10 +89,23 @@ module ActiveRecord # Clears the cache which maps classes def clear_reloadable_connections! - @@active_connections.each do |name, conn| - if conn.requires_reloading? - conn.disconnect! - @@active_connections.delete(name) + if @@allow_concurrency + # With concurrent connections @@active_connections is + # a hash keyed by thread id. + @@active_connections.each do |thread_id, conns| + conns.each do |name, conn| + if conn.requires_reloading? + conn.disconnect! + @@active_connections[thread_id].delete(name) + end + end + end + else + @@active_connections.each do |name, conn| + if conn.requires_reloading? + conn.disconnect! + @@active_connections.delete(name) + end end end end |