From 28229e4a77be19370f09ace0c03d20f333c15063 Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 31 May 2014 23:54:12 +0000 Subject: 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". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_marshal.rb | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index 64efe53bf5..0b7a121185 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -102,21 +102,19 @@ class TestMarshal < Test::Unit::TestCase 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) } -- cgit v1.2.3