diff options
author | Benoit Daloze <eregontp@gmail.com> | 2020-09-17 17:26:52 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2020-09-17 17:26:52 +0200 |
commit | d01954632d7cd6574d51c8cc95b832ad5f9de62d (patch) | |
tree | 2e1ef36466f9df8dae2a07f3378554c517abeed8 | |
parent | 264889ec3d3d38fc1fd23c4fb48402f1367a8deb (diff) |
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.
-rw-r--r-- | test/fiber/scheduler.rb | 3 | ||||
-rw-r--r-- | thread_sync.c | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/test/fiber/scheduler.rb b/test/fiber/scheduler.rb index 193a824f7f..43edcb27ed 100644 --- a/test/fiber/scheduler.rb +++ b/test/fiber/scheduler.rb @@ -135,7 +135,8 @@ class Scheduler @locking -= 1 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) # p [__method__, blocker, fiber] @lock.synchronize do diff --git a/thread_sync.c b/thread_sync.c index 10ff9c49b1..67d796233c 100644 --- a/thread_sync.c +++ b/thread_sync.c @@ -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) { rb_scheduler_unblock(cur->th->scheduler, cur->self, rb_fiberptr_self(cur->fiber)); + goto found; } else { switch (cur->th->status) { case THREAD_RUNNABLE: /* from someone else calling Thread#run */ |