summaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-25 09:57:52 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-25 09:57:52 +0000
commit183acaac292681644eb8df23341e03491104a4b6 (patch)
treef66cf655a414bb9edd465eeb67324fd204e6682f /io.c
parent799b5f163db678b8dbddd379440d006f7ebd86db (diff)
downloadruby-183acaac292681644eb8df23341e03491104a4b6.tar.gz
ruby-183acaac292681644eb8df23341e03491104a4b6.tar.xz
ruby-183acaac292681644eb8df23341e03491104a4b6.zip
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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@21039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/io.c b/io.c
index 6ae5ea9d8..23f56edf6 100644
--- a/io.c
+++ b/io.c
@@ -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) {