mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
9bd33790b7
commit
e78d4e69fe
4 changed files with 14 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Sat Dec 15 13:57:08 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
Sat Dec 15 13:38:30 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Sat Dec 15 13:38:30 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* io.c (io_flush_buffer): uses io_flush_buffer_async2 instead of
|
* io.c (io_flush_buffer): uses io_flush_buffer_async2 instead of
|
||||||
|
|
|
@ -283,6 +283,7 @@ VALUE rb_thread_shield_release(VALUE self);
|
||||||
VALUE rb_thread_shield_destroy(VALUE self);
|
VALUE rb_thread_shield_destroy(VALUE self);
|
||||||
void rb_mutex_allow_trap(VALUE self, int val);
|
void rb_mutex_allow_trap(VALUE self, int val);
|
||||||
VALUE rb_uninterruptible(VALUE (*b_proc)(ANYARGS), VALUE data);
|
VALUE rb_uninterruptible(VALUE (*b_proc)(ANYARGS), VALUE data);
|
||||||
|
VALUE rb_mutex_owned_p(VALUE self);
|
||||||
|
|
||||||
/* thread_pthread.c, thread_win32.c */
|
/* thread_pthread.c, thread_win32.c */
|
||||||
void Init_native_thread(void);
|
void Init_native_thread(void);
|
||||||
|
|
5
io.c
5
io.c
|
@ -1006,7 +1006,10 @@ static inline int
|
||||||
io_flush_buffer(rb_io_t *fptr)
|
io_flush_buffer(rb_io_t *fptr)
|
||||||
{
|
{
|
||||||
if (fptr->write_lock) {
|
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 {
|
else {
|
||||||
return (int)io_flush_buffer_async((VALUE)fptr);
|
return (int)io_flush_buffer_async((VALUE)fptr);
|
||||||
|
|
2
thread.c
2
thread.c
|
@ -4264,7 +4264,7 @@ rb_mutex_lock(VALUE self)
|
||||||
* Returns +true+ if this lock is currently held by current thread.
|
* Returns +true+ if this lock is currently held by current thread.
|
||||||
* <em>This API is experimental, and subject to change.</em>
|
* <em>This API is experimental, and subject to change.</em>
|
||||||
*/
|
*/
|
||||||
static VALUE
|
VALUE
|
||||||
rb_mutex_owned_p(VALUE self)
|
rb_mutex_owned_p(VALUE self)
|
||||||
{
|
{
|
||||||
VALUE owned = Qfalse;
|
VALUE owned = Qfalse;
|
||||||
|
|
Loading…
Reference in a new issue