From 6112d54151faf1b6398ce691f6756d810bf12f95 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 26 May 2014 08:40:37 +0000 Subject: [PATCH] test_rinda.rb: fix leaked threads * test/rinda/test_rinda.rb: join work threads not to leak threads. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rinda/test_rinda.rb | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb index f5472d28ac..196820117d 100644 --- a/test/rinda/test_rinda.rb +++ b/test/rinda/test_rinda.rb @@ -449,7 +449,12 @@ class TupleSpaceTest < Test::Unit::TestCase end def teardown # implementation-dependent - @ts.instance_eval{@keeper.kill if @keeper} + @ts.instance_eval{ + if th = @keeper + th.kill + th.join + end + } end end @@ -463,7 +468,12 @@ class TupleSpaceProxyTest < Test::Unit::TestCase end def teardown # implementation-dependent - @ts_base.instance_eval{@keeper.kill if @keeper} + @ts_base.instance_eval{ + if th = @keeper + th.kill + th.join + end + } end def test_remote_array_and_hash @@ -520,6 +530,7 @@ class TupleSpaceProxyTest < Test::Unit::TestCase Process.kill(signal, take) if take Process.wait(write) if write && status.nil? Process.wait(take) if take + service.stop_service end @server = DRb.primary_server || DRb.start_service @@ -554,7 +565,12 @@ class TestRingServer < Test::Unit::TestCase end def teardown # implementation-dependent - @ts.instance_eval{@keeper.kill if @keeper} + @ts.instance_eval{ + if th = @keeper + th.kill + th.join + end + } @rs.shutdown end @@ -641,6 +657,7 @@ class TestRingServer < Test::Unit::TestCase end def test_ring_server_ipv4_multicast + @rs.shutdown @rs = Rinda::RingServer.new(@ts, [['239.0.0.1', '0.0.0.0']], @port) v4mc = @rs.instance_variable_get('@sockets').first @@ -709,7 +726,10 @@ class TestRingServer < Test::Unit::TestCase end raise Timeout::Error, "timeout", bt ensure - th.kill if th + if th + th.kill + th.join + end Thread.abort_on_exception = aoe end