diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-25 09:57:52 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-25 09:57:52 +0000 |
commit | 107347961b4d7ab49799f0f3d2b0520c501d28be (patch) | |
tree | f66cf655a414bb9edd465eeb67324fd204e6682f /io.c | |
parent | 5b7d89de755390ae1a03f79b602c4fcc37f6559e (diff) |
merges r20988 from trunk into ruby_1_9_1.
* io.c (io_fflush): flush write buffer without write lock in
finalizers. [ruby-dev:37572]
* io.c (rb_io_fptr_finalize): clear write lock before finalizing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -558,7 +558,13 @@ io_fflush(rb_io_t *fptr) retry: if (fptr->wbuf_len == 0) return 0; - r = rb_mutex_synchronize(fptr->write_lock, io_flush_buffer, (VALUE)fptr); + if (fptr->write_lock) { + r = rb_mutex_synchronize(fptr->write_lock, io_flush_buffer, (VALUE)fptr); + } + else { + long l = io_writable_length(fptr, fptr->wbuf_len); + r = rb_write_internal(fptr->fd, fptr->wbuf+fptr->wbuf_off, l); + } /* xxx: Other threads may modify wbuf. * A lock is required, definitely. */ rb_io_check_closed(fptr); @@ -3176,6 +3182,7 @@ rb_io_fptr_finalize(rb_io_t *fptr) { if (!fptr) return 0; fptr->pathv = Qnil; + fptr->write_lock = 0; if (0 <= fptr->fd) rb_io_fptr_cleanup(fptr, Qtrue); if (fptr->rbuf) { |