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

allow Queue operation in trap.

* thread_sync.c: allow spurious wakeup to check Queue status just after trap.
  [Bug #12405]

* test/thread/test_queue.rb: add a test for it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-01-31 07:00:38 +00:00
parent 6897b3b985
commit bfdfc99cc2
2 changed files with 18 additions and 1 deletions

View file

@ -547,4 +547,21 @@ class TestQueue < Test::Unit::TestCase
# don't leak this thread
assert_nothing_raised{counter.join}
end
def test_queue_with_trap
assert_in_out_err([], <<-INPUT, %w(USR2 USR2 exit), [])
q = Queue.new
trap(:USR2){
q.push 'USR2'
}
Thread.new{
loop{
Process.kill :USR2, $$
}
}
puts q.pop
puts q.pop
puts 'exit'
INPUT
end
end

View file

@ -773,7 +773,7 @@ queue_delete_from_waiting(struct waiting_delete *p)
static VALUE
queue_sleep(VALUE arg)
{
rb_thread_sleep_deadly();
rb_thread_sleep_deadly_allow_spurious_wakeup();
return Qnil;
}