Project

General

Profile

ActionsLike0

Bug #9342

closed

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

Added by jsc (Justin Collins) about 11 years ago. Updated about 11 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

Added by Glass_saga (Masaki Matsushita) about 11 years ago

Revision 79e69ec7

  • 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

Added by nagachika (Tomoyuki Chikanaga) about 11 years ago

Revision 08e1428b

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

Revision d88502b7

  • 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

Revision a98f024d

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

ActionsLike0

Also available in: Atom PDF