summaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-30 15:33:03 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-30 15:33:03 +0000
commitfdc9afd6885a5f50d957e826c8694b72de70673d (patch)
treef6ffbb816a1fb52687c289d2e109fb02c32a5352 /io.c
parent64b8576b078a364ae83a005230a9dfcbe0c772c6 (diff)
downloadruby-fdc9afd6885a5f50d957e826c8694b72de70673d.tar.gz
ruby-fdc9afd6885a5f50d957e826c8694b72de70673d.tar.xz
ruby-fdc9afd6885a5f50d957e826c8694b72de70673d.zip
* string.c (rb_str_locktmp): lock string temporarily.
* string.c (str_independent): add tmplock check. * io.c (io_write): lock output string temporarily. [ruby-dev:24649] * io.c (io_write): use rb_str_locktmp(). * io.c (read_all): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@7149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/io.c b/io.c
index 2de3de7f4..3a8edcc4c 100644
--- a/io.c
+++ b/io.c
@@ -462,7 +462,9 @@ io_write(io, str)
rb_io_check_writable(fptr);
f = GetWriteFile(fptr);
+ rb_str_locktmp(str);
n = rb_io_fwrite(RSTRING(str)->ptr, RSTRING(str)->len, f);
+ rb_str_unlocktmp(str);
if (n == -1L) rb_sys_fail(fptr->path);
if (fptr->mode & FMODE_SYNC) {
io_fflush(f, fptr);
@@ -1011,10 +1013,10 @@ read_all(fptr, siz, str)
rb_str_resize(str, siz);
}
for (;;) {
- FL_SET(str, FL_FREEZE);
+ rb_str_locktmp(str);
READ_CHECK(fptr->f);
n = rb_io_fread(RSTRING(str)->ptr+bytes, siz-bytes, fptr->f);
- FL_UNSET(str, FL_FREEZE);
+ rb_str_unlocktmp(str);
if (n == 0 && bytes == 0) {
rb_str_resize(str,0);
if (!fptr->f) break;
@@ -1080,10 +1082,10 @@ io_read(argc, argv, io)
}
if (len == 0) return str;
- FL_SET(str, FL_FREEZE);
+ rb_str_locktmp(str);
READ_CHECK(fptr->f);
n = rb_io_fread(RSTRING(str)->ptr, len, fptr->f);
- FL_UNSET(str, FL_FREEZE);
+ rb_str_unlocktmp(str);
if (n == 0) {
rb_str_resize(str,0);
if (!fptr->f) return Qnil;