summaryrefslogtreecommitdiff
path: root/thread_sync.c
diff options
context:
space:
mode:
authorNeeraj Bhunwal <neeraj.bhunwal@gmail.com>2019-04-16 09:33:08 +0530
committerJeremy Evans <code@jeremyevans.net>2019-06-11 15:44:11 -0700
commitc1d78a7f0ece2004822193a0c1f1fd3dc38c2fdf (patch)
tree06ce88d1a91855c3bc6953032623653121ee9879 /thread_sync.c
parent5e018214e7435030727a97ac49db038d96438e74 (diff)
do_mutex_lock: release mutex before checking for interrupts (fixes issue 15360)
Diffstat (limited to 'thread_sync.c')
-rw-r--r--thread_sync.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/thread_sync.c b/thread_sync.c
index 2123458..c2612c1 100644
--- a/thread_sync.c
+++ b/thread_sync.c
@@ -282,14 +282,18 @@ do_mutex_lock(VALUE self, int interruptible_p)
th->status = prev_status;
}
th->vm->sleeper--;
- if (mutex->th == th) mutex_locked(th, self);
if (interruptible_p) {
+ /* release mutex before checking for interrupts...as interrupt checking
+ * code might call rb_raise() */
+ if (mutex->th == th) mutex->th = 0;
RUBY_VM_CHECK_INTS_BLOCKING(th->ec); /* may release mutex */
if (!mutex->th) {
mutex->th = th;
mutex_locked(th, self);
}
+ } else {
+ if (mutex->th == th) mutex_locked(th, self);
}
}
}