mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Fix Mutex#unlock with a scheduler and thread contention
* It would hit "[BUG] unexpected THREAD_STOPPED" before.
This commit is contained in:
parent
deffb63021
commit
264889ec3d
2 changed files with 36 additions and 13 deletions
|
@ -402,20 +402,20 @@ rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t *th, rb_fiber_t *fiber)
|
|||
|
||||
if (cur->th->scheduler != Qnil) {
|
||||
rb_scheduler_unblock(cur->th->scheduler, cur->self, rb_fiberptr_self(cur->fiber));
|
||||
} else {
|
||||
switch (cur->th->status) {
|
||||
case THREAD_RUNNABLE: /* from someone else calling Thread#run */
|
||||
case THREAD_STOPPED_FOREVER: /* likely (rb_mutex_lock) */
|
||||
rb_threadptr_interrupt(cur->th);
|
||||
goto found;
|
||||
case THREAD_STOPPED: /* probably impossible */
|
||||
rb_bug("unexpected THREAD_STOPPED");
|
||||
case THREAD_KILLED:
|
||||
/* not sure about this, possible in exit GC? */
|
||||
rb_bug("unexpected THREAD_KILLED");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
switch (cur->th->status) {
|
||||
case THREAD_RUNNABLE: /* from someone else calling Thread#run */
|
||||
case THREAD_STOPPED_FOREVER: /* likely (rb_mutex_lock) */
|
||||
rb_threadptr_interrupt(cur->th);
|
||||
goto found;
|
||||
case THREAD_STOPPED: /* probably impossible */
|
||||
rb_bug("unexpected THREAD_STOPPED");
|
||||
case THREAD_KILLED:
|
||||
/* not sure about this, possible in exit GC? */
|
||||
rb_bug("unexpected THREAD_KILLED");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
found:
|
||||
while (*th_mutex != mutex) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue