1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
akr 2014-05-31 23:54:12 +00:00
parent 70d34c623a
commit 28229e4a77

View file

@ -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) }