1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Add missing goto found;

* To still remove the lock from the Thread's list of acquired locks.
* Also to not wake up other waiters and preserve blocking behavior.
This commit is contained in:
Benoit Daloze 2020-09-17 17:26:52 +02:00
parent 264889ec3d
commit d01954632d
2 changed files with 3 additions and 1 deletions

View file

@ -135,7 +135,8 @@ class Scheduler
@locking -= 1 @locking -= 1
end end
# Used when synchronization wakes up a previously-blocked fiber (Mutex#unlock, Queue#push, ...) # Used when synchronization wakes up a previously-blocked fiber (Mutex#unlock, Queue#push, ...).
# This might be called from another thread.
def unblock(blocker, fiber) def unblock(blocker, fiber)
# p [__method__, blocker, fiber] # p [__method__, blocker, fiber]
@lock.synchronize do @lock.synchronize do

View file

@ -402,6 +402,7 @@ rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t *th, rb_fiber_t *fiber)
if (cur->th->scheduler != Qnil) { if (cur->th->scheduler != Qnil) {
rb_scheduler_unblock(cur->th->scheduler, cur->self, rb_fiberptr_self(cur->fiber)); rb_scheduler_unblock(cur->th->scheduler, cur->self, rb_fiberptr_self(cur->fiber));
goto found;
} else { } else {
switch (cur->th->status) { switch (cur->th->status) {
case THREAD_RUNNABLE: /* from someone else calling Thread#run */ case THREAD_RUNNABLE: /* from someone else calling Thread#run */