[前][次][番号順一覧][スレッド一覧]

ruby-changes:34058

From: nobu <ko1@a...>
Date: Mon, 26 May 2014 17:40:50 +0900 (JST)
Subject: [ruby-changes:34058] nobu:r46139 (trunk): test_rinda.rb: fix leaked threads

nobu	2014-05-26 17:40:37 +0900 (Mon, 26 May 2014)

  New Revision: 46139

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=46139

  Log:
    test_rinda.rb: fix leaked threads
    
    * test/rinda/test_rinda.rb: join work threads not to leak threads.

  Modified files:
    trunk/test/rinda/test_rinda.rb
Index: test/rinda/test_rinda.rb
===================================================================
--- test/rinda/test_rinda.rb	(revision 46138)
+++ test/rinda/test_rinda.rb	(revision 46139)
@@ -449,7 +449,12 @@ class TupleSpaceTest < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/rinda/test_rinda.rb#L449
   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:: https://github.com/ruby/ruby/blob/trunk/test/rinda/test_rinda.rb#L468
   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:: https://github.com/ruby/ruby/blob/trunk/test/rinda/test_rinda.rb#L530
     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::TestC https://github.com/ruby/ruby/blob/trunk/test/rinda/test_rinda.rb#L565
   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::TestC https://github.com/ruby/ruby/blob/trunk/test/rinda/test_rinda.rb#L657
   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::TestC https://github.com/ruby/ruby/blob/trunk/test/rinda/test_rinda.rb#L726
     end
     raise Timeout::Error, "timeout", bt
   ensure
-    th.kill if th
+    if th
+      th.kill
+      th.join
+    end
     Thread.abort_on_exception = aoe
   end
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]