summaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
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) {