mirror of
https://github.com/ruby/ruby.git
synced 2025-09-18 01:54:00 +02:00
merge revision(s) 53449: [Backport #11959]
* thread.c (rb_thread_pending_interrupt_p): no pending interrupt before initialization. * thread.c (thread_raise_m, rb_thread_kill): uninitialized thread cannot interrupt. [ruby-core:72732] [Bug #11959] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@56726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
04b031656a
commit
604f8be157
4 changed files with 42 additions and 6 deletions
13
thread.c
13
thread.c
|
@ -1546,6 +1546,14 @@ rb_threadptr_pending_interrupt_enque(rb_thread_t *th, VALUE v)
|
|||
th->pending_interrupt_queue_checked = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
threadptr_check_pending_interrupt_queue(rb_thread_t *th)
|
||||
{
|
||||
if (!th->pending_interrupt_queue) {
|
||||
rb_raise(rb_eThreadError, "uninitialized thread");
|
||||
}
|
||||
}
|
||||
|
||||
enum handle_interrupt_timing {
|
||||
INTERRUPT_NONE,
|
||||
INTERRUPT_IMMEDIATE,
|
||||
|
@ -1841,6 +1849,9 @@ rb_thread_pending_interrupt_p(int argc, VALUE *argv, VALUE target_thread)
|
|||
|
||||
GetThreadPtr(target_thread, target_th);
|
||||
|
||||
if (!target_th->pending_interrupt_queue) {
|
||||
return Qfalse;
|
||||
}
|
||||
if (rb_threadptr_pending_interrupt_empty_p(target_th)) {
|
||||
return Qfalse;
|
||||
}
|
||||
|
@ -2154,6 +2165,7 @@ thread_raise_m(int argc, VALUE *argv, VALUE self)
|
|||
rb_thread_t *target_th;
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
GetThreadPtr(self, target_th);
|
||||
threadptr_check_pending_interrupt_queue(target_th);
|
||||
rb_threadptr_raise(target_th, argc, argv);
|
||||
|
||||
/* To perform Thread.current.raise as Kernel.raise */
|
||||
|
@ -2198,6 +2210,7 @@ rb_thread_kill(VALUE thread)
|
|||
rb_threadptr_to_kill(th);
|
||||
}
|
||||
else {
|
||||
threadptr_check_pending_interrupt_queue(th);
|
||||
rb_threadptr_pending_interrupt_enque(th, eKillSignal);
|
||||
rb_threadptr_interrupt(th);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue