aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-03-08 15:40:23 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-03-08 15:47:18 -0800
commitcff19cf545de61ada8904d9d3daaaa594a9a931f (patch)
treef48585317c6bcfb42acabd5498a9d8e591f99778 /activerecord/lib/active_record/connection_adapters
parent263d8424b36a80aa44ade979c4eaf686a58a99aa (diff)
downloadrails-cff19cf545de61ada8904d9d3daaaa594a9a931f.tar.gz
rails-cff19cf545de61ada8904d9d3daaaa594a9a931f.tar.bz2
rails-cff19cf545de61ada8904d9d3daaaa594a9a931f.zip
make active_connection? return true only if there is an open connection in use for the current thread. fixes #5330
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb7
1 files changed, 4 insertions, 3 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 698da34d26..7e8d13a030 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -95,10 +95,11 @@ module ActiveRecord
@reserved_connections[current_connection_id] ||= checkout
end
- # Check to see if there is an active connection in this connection
- # pool.
+ # Is there an open connection that is being used for the current thread?
def active_connection?
- active_connections.any?
+ @reserved_connections.fetch(current_connection_id) {
+ return false
+ }.in_use?
end
# Signal that the thread is finished with the current connection.