diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-28 09:33:35 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-28 09:33:35 +0000 |
commit | 9b02a72d7183f3a76636f1168429e5d229409c66 (patch) | |
tree | 86dba5aa9318349ed4b68bd2e0f59b5b9c428da9 /test | |
parent | 007b7fcdcf709cbffb2ee2c6c01f9edf4daaccac (diff) | |
download | ruby-9b02a72d7183f3a76636f1168429e5d229409c66.tar.gz |
* io.c (io_fread, io_getpartial, rb_io_sysread): set buffer size
after check if readable, which can cause thread switch.
[ruby-dev:45297][Bug #6099]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_io.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index ebddf14d5e..11f8097479 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2240,4 +2240,37 @@ End assert_equal(1, $stdout.fileno) assert_equal(2, $stderr.fileno) end + + def test_sysread_locktmp + bug6099 = '[ruby-dev:45297]' + buf = " " * 100 + data = "a" * 100 + with_pipe do |r,w| + th = Thread.new {r.sysread(100, buf)} + Thread.pass until th.stop? + buf.replace("") + assert_empty(buf) + w.write(data) + Thread.pass while th.alive? + th.join + end + assert_equal(data, buf) + end + + def test_readpartial_locktmp + bug6099 = '[ruby-dev:45297]' + buf = " " * 100 + data = "a" * 100 + with_pipe do |r,w| + r.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK) + th = Thread.new {r.readpartial(100, buf)} + Thread.pass until th.stop? + buf.replace("") + assert_empty(buf) + w.write(data) + Thread.pass while th.alive? + th.join + end + assert_equal(data, buf) + end end |