aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-25 14:34:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-25 14:34:07 +0000
commit61701ae1675f790ee3f59207283642dbe64c2d37 (patch)
tree89c4fa4d83f1e8308c02485ea8623b823b697343 /test/ruby
parenta7bc6c1b8fb2cd2826f541fb159994752158fbee (diff)
downloadruby-61701ae1675f790ee3f59207283642dbe64c2d37.tar.gz
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/trunk@57422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_io.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 4c224a247f..b16662cd42 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -3397,6 +3397,27 @@ __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
+
if RUBY_ENGINE == "ruby" # implementation details
def test_foreach_rs_conversion
make_tempfile {|t|