Project

General

Profile

Actions

Bug #9342

closed

[PATCH] SizedQueue#clear does not notify waiting threads in Ruby 1.9.3

Added by jsc (Justin Collins) almost 11 years ago. Updated over 10 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-darwin11.4.2]
[ruby-core:59462]

Description

In Ruby 1.9.3, when SizedQueue#clear is called, it empties the queue but does not notify waiting threads that the queue is empty. This typically leads to deadlock when the queue is full.

For example:

sq = SizedQueue.new(1)
sq << 1 # Fill queue

t1 = Thread.new do
sq << 1 # Attempt to add another item to queue, fail and go to sleep waiting
end

t2 = Thread.new do
Thread.pass
sq.clear
end

t2.join # Empty queue
t1.join # Deadlock, t1 continues to sleep


Files

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0