diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-27 16:54:09 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-27 16:54:09 +0000 |
commit | 65639d44e962419bc1da1f1dfbec232abcced6cd (patch) | |
tree | dc2ace0c0068be2cf528397512ef4ead2b4eee3c /test/ruby/test_io.rb | |
parent | d8a1986a05110b2468a256ab94936ef482f010bb (diff) |
merge revision(s) 57422: [Backport #13158]
io.c: close before wait
* io.c (io_close_fptr): notify then close, and wait for other
threads before free fptr. [ruby-core:79262] [Bug #13158]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@58177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r-- | test/ruby/test_io.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 70c46d55b1..13a4af1b82 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -3315,4 +3315,25 @@ End end end; end + + def test_race_closed_stream + bug13158 = '[ruby-core:79262] [Bug #13158]' + closed = nil + IO.pipe do |r, w| + thread = Thread.new do + begin + while r.gets + end + ensure + closed = r.closed? + end + end + sleep 0.01 + r.close + assert_raise_with_message(IOError, /stream closed/) do + thread.join + end + assert_equal(true, closed, "#{bug13158}: stream should be closed") + end + end end |