summaryrefslogtreecommitdiff
path: root/thread_sync.c
diff options
context:
space:
mode:
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 2123458127..c2612c1415 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);
}
}
}