thread_sync.c (rb_mutex_lock): fix deadlock
* thread_sync.c (rb_mutex_lock): fix deadlock [ruby-core:87467] [Bug #14841] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0af19735d7
commit
501069b8a4
@ -272,15 +272,11 @@ rb_mutex_lock(VALUE self)
|
|||||||
list_add_tail(&mutex->waitq, &w.node);
|
list_add_tail(&mutex->waitq, &w.node);
|
||||||
native_sleep(th, timeout); /* release GVL */
|
native_sleep(th, timeout); /* release GVL */
|
||||||
list_del(&w.node);
|
list_del(&w.node);
|
||||||
if (!mutex->th) {
|
|
||||||
mutex->th = th;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (patrol_thread == th)
|
if (patrol_thread == th)
|
||||||
patrol_thread = NULL;
|
patrol_thread = NULL;
|
||||||
|
|
||||||
th->locking_mutex = Qfalse;
|
th->locking_mutex = Qfalse;
|
||||||
if (mutex->th && timeout && !RUBY_VM_INTERRUPTED(th->ec)) {
|
if (timeout && !RUBY_VM_INTERRUPTED(th->ec)) {
|
||||||
rb_check_deadlock(th->vm);
|
rb_check_deadlock(th->vm);
|
||||||
}
|
}
|
||||||
if (th->status == THREAD_STOPPED_FOREVER) {
|
if (th->status == THREAD_STOPPED_FOREVER) {
|
||||||
@ -288,9 +284,11 @@ rb_mutex_lock(VALUE self)
|
|||||||
}
|
}
|
||||||
th->vm->sleeper--;
|
th->vm->sleeper--;
|
||||||
|
|
||||||
if (mutex->th == th) mutex_locked(th, self);
|
RUBY_VM_CHECK_INTS_BLOCKING(th->ec); /* may release mutex */
|
||||||
|
if (!mutex->th) {
|
||||||
RUBY_VM_CHECK_INTS_BLOCKING(th->ec);
|
mutex->th = th;
|
||||||
|
mutex_locked(th, self);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user