summaryrefslogtreecommitdiff
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
commitc2a9b62fd2f5c107fcff2e21052e4e9e2294e8ce (patch)
treef6ffbb816a1fb52687c289d2e109fb02c32a5352 /io.c
parente7bb5176f67ac39add861b6539fe40898f2af6c0 (diff)
* 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: svn+ssh://ci.ruby-lang.org/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 2de3de7..3a8edcc 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;