提交 5dc7257b 编写于 作者: A Aaron Patterson

refactor checking out the connection

上级 df9de6fc
......@@ -186,13 +186,14 @@ def clear_stale_cached_connections!
def checkout
# Checkout an available connection
synchronize do
# Try to find a connection that hasn't been leased
conn = @connections.find { |c| c.lease }
unless conn
if @connections.size < @size
conn = checkout_new_connection
conn.lease
end
# If all connections were leased, and we have room to expand,
# create a new connection and lease it.
if !conn && @connections.size < @size
conn = checkout_new_connection
conn.lease
end
if conn
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册