diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-03-17 17:13:00 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-03-17 17:13:00 -0700 |
commit | 8f218266bb4fa4ef2a07904b106c72fda9e182a6 (patch) | |
tree | 3065ab1e65e9577c11e04d51f12c56e4da4dba69 /activerecord/test/cases/reaper_test.rb | |
parent | 4a69c933cf07ee296a4ae1e2612c31922019eeab (diff) | |
parent | 9e457a8654fa89fe329719f88ae3679aefb21e56 (diff) | |
download | rails-8f218266bb4fa4ef2a07904b106c72fda9e182a6.tar.gz rails-8f218266bb4fa4ef2a07904b106c72fda9e182a6.tar.bz2 rails-8f218266bb4fa4ef2a07904b106c72fda9e182a6.zip |
Merge pull request #14360 from matthewd/thread_aware_reaper
Track owning thread for connection pool
Diffstat (limited to 'activerecord/test/cases/reaper_test.rb')
-rw-r--r-- | activerecord/test/cases/reaper_test.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/activerecord/test/cases/reaper_test.rb b/activerecord/test/cases/reaper_test.rb index 015c37cce8..f52fd22489 100644 --- a/activerecord/test/cases/reaper_test.rb +++ b/activerecord/test/cases/reaper_test.rb @@ -63,17 +63,22 @@ module ActiveRecord spec.config[:reaping_frequency] = 0.0001 pool = ConnectionPool.new spec - pool.dead_connection_timeout = 0 - conn = pool.checkout - count = pool.connections.length + conn = nil + child = Thread.new do + conn = pool.checkout + Thread.stop + end + Thread.pass while conn.nil? + + assert conn.in_use? - conn.extend(Module.new { def active_threadsafe?; false; end; }) + child.terminate - while count == pool.connections.length + while conn.in_use? Thread.pass end - assert_equal(count - 1, pool.connections.length) + assert !conn.in_use? end end end |