aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
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:40:23 -0800
commitd523504c2f18e459e21a8cfa019ef0620db61b79 (patch)
tree87d7d68299144a8670d83ceaf4a19fb8b3d7017c /activerecord/lib/active_record
parent8a714c4d804d2502c4b1bdfccb3e9175c4add7b8 (diff)
downloadrails-d523504c2f18e459e21a8cfa019ef0620db61b79.tar.gz
rails-d523504c2f18e459e21a8cfa019ef0620db61b79.tar.bz2
rails-d523504c2f18e459e21a8cfa019ef0620db61b79.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')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb11
1 files changed, 4 insertions, 7 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 37a9d216df..eb88f191a7 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -128,10 +128,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.
@@ -288,10 +289,6 @@ module ActiveRecord
end
c
end
-
- def active_connections
- @connections.find_all { |c| c.in_use? }
- end
end
# ConnectionHandler is a collection of ConnectionPool objects. It is used