Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

deal with removing connections associated with the current thread

  • Loading branch information...
commit e060cf01a5e05bc6eaeee90b8c421d2aa6435b7c 1 parent 17ff88c
@tenderlove tenderlove authored
View
7 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -222,6 +222,13 @@ def checkin(conn)
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
View
8 activerecord/test/cases/connection_pool_test.rb
@@ -37,6 +37,14 @@ def test_remove_connection
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
Please sign in to comment.
Something went wrong with that request. Please try again.