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

ruby-changes:34214

From: akr <ko1@a...>
Date: Mon, 2 Jun 2014 09:31:40 +0900 (JST)
Subject: [ruby-changes:34214] akr:r46290 (trunk): Join threads before close pipes.

akr	2014-06-01 08:54:12 +0900 (Sun, 01 Jun 2014)

  New Revision: 46290

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

  Log:
    Join threads before close pipes.
    
    closing a FD interrupts threads which uses the FD.
    rb_thread_io_blocking_region (for write()) checks an interrupt after write() is finished.
    So, joining the thread after closing() may raise "IOError: stream closed".

  Modified files:
    trunk/test/ruby/test_marshal.rb
Index: test/ruby/test_marshal.rb
===================================================================
--- test/ruby/test_marshal.rb	(revision 46289)
+++ test/ruby/test_marshal.rb	(revision 46290)
@@ -102,21 +102,19 @@ class TestMarshal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_marshal.rb#L102
   def test_pipe
     o1 = C.new("a" * 10000)
 
-    th = nil
-
-    o2 = IO.pipe do |r, w|
+    IO.pipe do |r, w|
       th = Thread.new {Marshal.dump(o1, w)}
-      Marshal.load(r)
+      o2 = Marshal.load(r)
+      th.join
+      assert_equal(o1.str, o2.str)
     end
-    assert_equal(o1.str, o2.str)
-    th.join
 
-    o2 = IO.pipe do |r, w|
+    IO.pipe do |r, w|
       th = Thread.new {Marshal.dump(o1, w, 2)}
-      Marshal.load(r)
+      o2 = Marshal.load(r)
+      th.join
+      assert_equal(o1.str, o2.str)
     end
-    assert_equal(o1.str, o2.str)
-    th.join
 
     assert_raise(TypeError) { Marshal.dump("foo", Object.new) }
     assert_raise(TypeError) { Marshal.load(Object.new) }

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

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