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

do_mutex_lock: release mutex before checking for interrupts (fixes issue 15360)

This commit is contained in:
Neeraj Bhunwal 2019-04-16 09:33:08 +05:30 committed by Jeremy Evans
parent 5e018214e7
commit c1d78a7f0e

View file

@ -282,14 +282,18 @@ do_mutex_lock(VALUE self, int interruptible_p)
th->status = prev_status; th->status = prev_status;
} }
th->vm->sleeper--; th->vm->sleeper--;
if (mutex->th == th) mutex_locked(th, self);
if (interruptible_p) { 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 */ RUBY_VM_CHECK_INTS_BLOCKING(th->ec); /* may release mutex */
if (!mutex->th) { if (!mutex->th) {
mutex->th = th; mutex->th = th;
mutex_locked(th, self); mutex_locked(th, self);
} }
} else {
if (mutex->th == th) mutex_locked(th, self);
} }
} }
} }