summaryrefslogtreecommitdiffstats
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
parent799b5f163db678b8dbddd379440d006f7ebd86db (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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@21039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--io.c9
2 files changed, 15 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 44dae40fe..cde230891 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Dec 25 15:54:00 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * 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.
+
Thu Dec 25 15:07:22 2008 Tanaka Akira <akr@fsij.org>
* io.c (fptr_finalize): close the IO object even if close(2) is failed.
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) {