From ce3d8d646a7a4077907b1ec2bad5101840d989e5 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 29 Nov 2011 13:56:24 -0800 Subject: Start implementing @reserved_connections in terms of connection leases. --- .../active_record/connection_adapters/abstract/connection_pool.rb | 6 +++--- 1 file changed, 3 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 0b3971a0a6..04465db61d 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -97,7 +97,7 @@ module ActiveRecord # Check to see if there is an active connection in this connection # pool. def active_connection? - @reserved_connections.key? current_connection_id + active_connections.any? end # Signal that the thread is finished with the current connection. @@ -113,7 +113,7 @@ module ActiveRecord # connection when finished. def with_connection connection_id = current_connection_id - fresh_connection = true unless @reserved_connections[connection_id] + fresh_connection = true unless active_connection? yield connection ensure release_connection(connection_id) if fresh_connection @@ -121,7 +121,7 @@ module ActiveRecord # Returns true if a connection has already been opened. def connected? - !@connections.empty? + @connections.any? end # Disconnects all connections in the pool, and clears the pool. -- cgit v1.2.3