Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding active_connection? to the connection pool

  • Loading branch information...
commit 4211866b7a1d0abf0c9150fd61ea67a8043b831d 1 parent ec0cacc
@tenderlove tenderlove authored
View
6 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -151,6 +151,12 @@ def connection
@reserved_connections[current_connection_id] ||= checkout
end
+ # Check to see if there is an active connection in this connection
+ # pool.
+ def active_connection?
+ @reserved_connections.key? current_connection_id
+ end
+
# Signal that the thread is finished with the current connection.
# #release_connection releases the connection-thread association
# and returns the connection to the pool.
View
8 activerecord/test/cases/connection_pool_test.rb
@@ -18,6 +18,14 @@ def setup
end
end
+ def test_active_connection?
+ assert !@pool.active_connection?
+ assert @pool.connection
+ assert @pool.active_connection?
+ @pool.release_connection
+ assert !@pool.active_connection?
+ end
+
def test_pool_caches_columns
columns = @pool.columns['posts']
assert_equal columns, @pool.columns['posts']
Please sign in to comment.
Something went wrong with that request. Please try again.