提交 23fad29c 编写于 作者: A Aaron Patterson

Merge pull request #6398 from pmahoney/threadsafe-connection-pool

Synchronize read and modification of @reserved_connections 
......@@ -139,15 +139,19 @@ def initialize(spec)
# #connection can be called any number of times; the connection is
# held in a hash keyed by the thread id.
def connection
synchronize do
@reserved_connections[current_connection_id] ||= checkout
end
end
# Is there an open connection that is being used for the current thread?
def active_connection?
synchronize do
@reserved_connections.fetch(current_connection_id) {
return false
}.in_use?
end
end
# Signal that the thread is finished with the current connection.
# #release_connection releases the connection-thread association
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册