Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

reduce the number of times current_connection_id is called in with_co…

…nnection()
  • Loading branch information...
commit 334452098e593bb514a9ea2bd74435f2c7b0628e 1 parent e1596be
@tenderlove tenderlove authored
View
9 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -103,8 +103,8 @@ def connection
# 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 @@ def release_connection
# 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.
Please sign in to comment.
Something went wrong with that request. Please try again.