aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-31 23:54:12 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-31 23:54:12 +0000
commit28229e4a77be19370f09ace0c03d20f333c15063 (patch)
treebd993ef8c0b2e3491be2bd97a2e8e3b126889048 /test
parent70d34c623a4a35f15936b7b7fecd618aeb0521d3 (diff)
downloadruby-28229e4a77be19370f09ace0c03d20f333c15063.tar.gz
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')
-rw-r--r--test/ruby/test_marshal.rb18
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) }