mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
e623ceb9f9
commit
6effaa9a13
3 changed files with 30 additions and 0 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Sat Jun 18 23:59:24 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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
|
||||||
|
|
||||||
Sat Jun 18 21:36:29 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Sat Jun 18 21:36:29 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* thread_pthread.c: remove GVL_DEBUG
|
* thread_pthread.c: remove GVL_DEBUG
|
||||||
|
|
3
io.c
3
io.c
|
@ -1717,6 +1717,9 @@ fill_cbuf(rb_io_t *fptr, int ec_flags)
|
||||||
if (fptr->rbuf.len == 0) {
|
if (fptr->rbuf.len == 0) {
|
||||||
READ_CHECK(fptr);
|
READ_CHECK(fptr);
|
||||||
if (io_fillbuf(fptr) == -1) {
|
if (io_fillbuf(fptr) == -1) {
|
||||||
|
if (!fptr->readconv) {
|
||||||
|
return MORE_CHAR_FINISHED;
|
||||||
|
}
|
||||||
ds = dp = (unsigned char *)fptr->cbuf.ptr + fptr->cbuf.off + fptr->cbuf.len;
|
ds = dp = (unsigned char *)fptr->cbuf.ptr + fptr->cbuf.off + fptr->cbuf.len;
|
||||||
de = (unsigned char *)fptr->cbuf.ptr + fptr->cbuf.capa;
|
de = (unsigned char *)fptr->cbuf.ptr + fptr->cbuf.capa;
|
||||||
res = rb_econv_convert(fptr->readconv, NULL, NULL, &dp, de, 0);
|
res = rb_econv_convert(fptr->readconv, NULL, NULL, &dp, de, 0);
|
||||||
|
|
|
@ -1955,4 +1955,24 @@ End
|
||||||
assert_nothing_raised(TypeError) { File.binwrite(path, "string", mode: "w", encoding: "EUC-JP") }
|
assert_nothing_raised(TypeError) { File.binwrite(path, "string", mode: "w", encoding: "EUC-JP") }
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue