mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
deal with removing connections associated with the current thread
This commit is contained in:
parent
17ff88c4d4
commit
e060cf01a5
2 changed files with 15 additions and 0 deletions
|
@ -222,6 +222,13 @@ module ActiveRecord
|
|||
def remove(conn)
|
||||
synchronize do
|
||||
@connections.delete conn
|
||||
|
||||
# FIXME: we might want to store the key on the connection so that removing
|
||||
# from the reserved hash will be a little easier.
|
||||
thread_id = @reserved_connections.keys.find { |k|
|
||||
@reserved_connections[k] == conn
|
||||
}
|
||||
@reserved_connections.delete thread_id if thread_id
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -37,6 +37,14 @@ module ActiveRecord
|
|||
conn.close
|
||||
end
|
||||
|
||||
def test_remove_connection_for_thread
|
||||
conn = @pool.connection
|
||||
@pool.remove conn
|
||||
assert_not_equal(conn, @pool.connection)
|
||||
ensure
|
||||
conn.close
|
||||
end
|
||||
|
||||
def test_active_connection?
|
||||
assert !@pool.active_connection?
|
||||
assert @pool.connection
|
||||
|
|
Loading…
Reference in a new issue