diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-18 15:00:00 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-18 15:00:00 +0000 |
commit | 6effaa9a139eadf99a606af293e4d39ce6dc1182 (patch) | |
tree | 18a361adb79338b8a83770a90de7a42eb416095b /test | |
parent | e623ceb9f9092616be590b1f5e1a71ddbb18c0b3 (diff) |
* io.c (fill_cbuf): finish reading at EOF, and the readconv has
been cleared by another thread while io_fillbuf() is waiting at
select(). a patch in [ruby-core:37197] by Hiroshi Shirosaki
<h.shirosaki AT gmail.com>. fixed #3840
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_io.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 3df7771d6c..0325867496 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1955,4 +1955,24 @@ End assert_nothing_raised(TypeError) { File.binwrite(path, "string", mode: "w", encoding: "EUC-JP") } end end + + def test_race_between_read + file = Tempfile.new("test") + path = file.path + file.close + write_file = File.open(path, "wt") + read_file = File.open(path, "rt") + + threads = [] + 10.times do |i| + threads << Thread.new {write_file.print(i)} + threads << Thread.new {read_file.read} + end + threads.each {|t| t.join} + assert(true, "[ruby-core:37197]") + ensure + read_file.close + write_file.close + file.close! + end end |