Project

General

Profile

Bug #9302 ยป 0001-thread-fix-deadlock-freeze-on-SizedQueue-push.patch

normalperson (Eric Wong), 12/26/2013 07:07 PM

View differences:

ext/thread/thread.c
rb_szqueue_push(VALUE self, VALUE obj)
{
struct waiting_delete args;
args.waiting = GET_QUEUE_WAITERS(self);
args.waiting = GET_SZQUEUE_WAITERS(self);
args.th = rb_thread_current();
while (queue_length(self) >= GET_SZQUEUE_ULONGMAX(self)) {
test/thread/test_queue.rb
assert_same q, retval
end
def test_sized_queue_throttle
q = SizedQueue.new(1)
i = 0
consumer = Thread.new do
while q.pop
i += 1
Thread.pass
end
end
nprod = 4
npush = 100
producer = nprod.times.map do
Thread.new do
npush.times { q.push(true) }
end
end
producer.each(&:join)
q.push(nil)
consumer.join
assert_equal(nprod * npush, i)
end
def test_queue_thread_raise
q = Queue.new
th1 = Thread.new do
    (1-1/1)