diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-25 06:55:38 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-25 06:55:38 +0000 |
commit | ad558a3a7f13ad2ad1004bf0ed44c192b98bb529 (patch) | |
tree | 6cc0ff13be0974ec0029fa567bf8936d526cf534 /io.c | |
parent | f20234994e8589a974bd6f2e057055b2e521f9ed (diff) |
* 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/trunk@20988 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); @@ -3190,6 +3196,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) { |