1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

connections are only removed if they are inactve

This commit is contained in:
Aaron Patterson 2011-12-30 14:31:30 -08:00
parent 86729eb733
commit b1ac881433
2 changed files with 19 additions and 3 deletions

View file

@ -239,7 +239,7 @@ module ActiveRecord
synchronize do
stale = Time.now - @timeout
connections.dup.each do |conn|
remove conn if conn.in_use? && stale > conn.last_use
remove conn if conn.in_use? && stale > conn.last_use && !conn.active?
end
end
end

View file

@ -25,7 +25,7 @@ module ActiveRecord
@pool.connections.each(&:close)
end
def test_reap
def test_reap_and_active
@pool.checkout
@pool.checkout
@pool.checkout
@ -35,9 +35,25 @@ module ActiveRecord
@pool.reap
assert_equal connections.length, @pool.connections.length
end
def test_reap_inactive
@pool.checkout
@pool.checkout
@pool.checkout
@pool.timeout = 0
connections = @pool.connections.dup
connections.each do |conn|
conn.extend(Module.new { def active?; false; end; })
end
@pool.reap
assert_equal 0, @pool.connections.length
ensure
connections.map(&:close)
connections.each(&:close)
end
def test_remove_connection