diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-10-06 02:52:26 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-10-06 02:52:26 +0000 |
commit | 915ae780c37478fea358d6c77513a728e86a10f2 (patch) | |
tree | 7776a2822ff87357d287ef8a11609b00f01e66d0 /io.c | |
parent | a413c84e543528d31190f22ecdf1a5f7363cedc9 (diff) | |
download | ruby-915ae780c37478fea358d6c77513a728e86a10f2.tar.gz |
* io.c (fptr_finalize): write_mutex might have been destroyed
already in finalization phase, as the order of finalizers is not
guaranteed. rb_mutex_t should be used in place of Mutex object
in the future.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -3459,7 +3459,7 @@ fptr_finalize(rb_io_t *fptr, int noraise) { VALUE err = Qnil; if (fptr->writeconv) { - if (fptr->write_lock) { + if (fptr->write_lock && !noraise) { struct finish_writeconv_arg arg; arg.fptr = fptr; arg.noalloc = noraise; @@ -3470,8 +3470,14 @@ fptr_finalize(rb_io_t *fptr, int noraise) } } if (fptr->wbuf_len) { - if (io_fflush(fptr) < 0 && NIL_P(err)) - err = noraise ? Qtrue : INT2NUM(errno); + if (noraise) { + if ((int)io_flush_buffer_sync(fptr) < 0 && NIL_P(err)) + err = Qtrue; + } + else { + if (io_fflush(fptr) < 0 && NIL_P(err)) + err = INT2NUM(errno); + } } if (IS_PREP_STDIO(fptr) || fptr->fd <= 2) { goto skip_fd_close; |