aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-08-06 16:38:53 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-08-06 16:39:12 -0700
commit334452098e593bb514a9ea2bd74435f2c7b0628e (patch)
tree205dbac406fc1c3309033ef97330df161acfdaa0 /activerecord
parente1596be32363122f12777ce09e654ae58f262eb4 (diff)
downloadrails-334452098e593bb514a9ea2bd74435f2c7b0628e.tar.gz
rails-334452098e593bb514a9ea2bd74435f2c7b0628e.tar.bz2
rails-334452098e593bb514a9ea2bd74435f2c7b0628e.zip
reduce the number of times current_connection_id is called in with_connection()
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb9
1 files changed, 5 insertions, 4 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 9d0251dda3..02a8f4e214 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -103,8 +103,8 @@ module ActiveRecord
# Signal that the thread is finished with the current connection.
# #release_connection releases the connection-thread association
# and returns the connection to the pool.
- def release_connection
- conn = @reserved_connections.delete(current_connection_id)
+ def release_connection(with_id = current_connection_id)
+ conn = @reserved_connections.delete(with_id)
checkin conn if conn
end
@@ -112,10 +112,11 @@ module ActiveRecord
# exists checkout a connection, yield it to the block, and checkin the
# connection when finished.
def with_connection
- fresh_connection = true unless @reserved_connections[current_connection_id]
+ connection_id = current_connection_id
+ fresh_connection = true unless @reserved_connections[connection_id]
yield connection
ensure
- release_connection if fresh_connection
+ release_connection(connection_id) if fresh_connection
end
# Returns true if a connection has already been opened.