Bug #9342
closed[PATCH] SizedQueue#clear does not notify waiting threads in Ruby 1.9.3
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
Added by nagachika (Tomoyuki Chikanaga) about 11 years ago
merge revision(s) 44595: [Backport #9342]
* ext/thread/thread.c (rb_szqueue_clear): notify SZQUEUE_WAITERS
on SizedQueue#clear. [ruby-core:59462] [Bug #9342]
* test/thread/test_queue.rb: add test. the patch is from
Justin Collins.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@44899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Added by U.Nakamura about 11 years ago
-
lib/thread.rb (SizedQueue#clear): wake waiting threads when called.
[Bug #9342] [ruby-core:59462] -
test/thread/test_queue.rb: add a test for above.
patched by Justin Collins.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@44932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Added by naruse (Yui NARUSE) about 11 years ago
merge revision(s) 44595: [Backport #9342]
* ext/thread/thread.c (rb_szqueue_clear): notify SZQUEUE_WAITERS
on SizedQueue#clear. [ruby-core:59462] [Bug #9342]
* test/thread/test_queue.rb: add test. the patch is from
Justin Collins.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
ext/thread/thread.c (rb_szqueue_clear): notify SZQUEUE_WAITERS
on SizedQueue#clear. [ruby-core:59462] [Bug #9342]
test/thread/test_queue.rb: add test. the patch is from
Justin Collins.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e