diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-15 05:40:18 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-15 05:40:18 +0000 |
commit | e78d4e69fe15b84358ce8fb30edf5c6610a6bad9 (patch) | |
tree | 5830fe451bd74508e6f77b29b0e18b6c2a8e56df /io.c | |
parent | 9bd33790b7f992520f003954df743dd6e8502622 (diff) | |
download | ruby-e78d4e69fe15b84358ce8fb30edf5c6610a6bad9.tar.gz |
* thread.c (rb_mutex_owned_p): remove static.
* io.c (io_flush_buffer): don't hold mutex if already have.
Now recursive lock may occur when following scenario.
fptr_finalize -> finish_writeconv_sync -> finish_writeconv
-> io_fflush.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -1006,7 +1006,10 @@ static inline int io_flush_buffer(rb_io_t *fptr) { if (fptr->write_lock) { - return (int)rb_mutex_synchronize(fptr->write_lock, io_flush_buffer_async2, (VALUE)fptr); + if (rb_mutex_owned_p(fptr->write_lock)) + return (int)io_flush_buffer_async2((VALUE)fptr); + else + return (int)rb_mutex_synchronize(fptr->write_lock, io_flush_buffer_async2, (VALUE)fptr); } else { return (int)io_flush_buffer_async((VALUE)fptr); |