aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
diff options
context:
space:
mode:
authorBrian Lopez <seniorlopez@gmail.com>2010-08-09 12:43:49 -0700
committerBrian Lopez <seniorlopez@gmail.com>2010-08-09 12:43:49 -0700
commitee9c950f2fe0c7953f0a9ad6a53439da7a4e89bc (patch)
tree1b3f6a3e49be0ebacb251de0c0fc12bf64e2e596 /activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
parentd8b90114ddd2a432280d114b9fe4ef1fdb38d132 (diff)
parent7171161124a2852ee7b40c5c632ba8e092c97409 (diff)
downloadrails-ee9c950f2fe0c7953f0a9ad6a53439da7a4e89bc.tar.gz
rails-ee9c950f2fe0c7953f0a9ad6a53439da7a4e89bc.tar.bz2
rails-ee9c950f2fe0c7953f0a9ad6a53439da7a4e89bc.zip
bringing over latest from master
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb')
-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.