diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-31 23:54:12 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-31 23:54:12 +0000 |
commit | 28229e4a77be19370f09ace0c03d20f333c15063 (patch) | |
tree | bd993ef8c0b2e3491be2bd97a2e8e3b126889048 /test/ruby/test_marshal.rb | |
parent | 70d34c623a4a35f15936b7b7fecd618aeb0521d3 (diff) |
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
Diffstat (limited to 'test/ruby/test_marshal.rb')
-rw-r--r-- | test/ruby/test_marshal.rb | 18 |
1 files changed, 8 insertions, 10 deletions
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) } |