ruby-changes:32773
From: normal <ko1@a...>
Date: Thu, 6 Feb 2014 08:35:11 +0900 (JST)
Subject: [ruby-changes:32773] normal:r44852 (trunk): ext/thread: SizedQueue#max= wakes up waiters properly
normal 2014-02-06 08:35:06 +0900 (Thu, 06 Feb 2014) New Revision: 44852 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44852 Log: ext/thread: SizedQueue#max= wakes up waiters properly * ext/thread/thread.c (rb_szqueue_max_set): use correct queue and limit wakeups. [Bug #9343][ruby-core:60517] * test/thread/test_queue.rb (test_sized_queue_assign_max): test for bug Modified files: trunk/ChangeLog trunk/ext/thread/thread.c trunk/test/thread/test_queue.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 44851) +++ ChangeLog (revision 44852) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Feb 6 08:23:28 2014 Eric Wong <e@8...> + + * ext/thread/thread.c (rb_szqueue_max_set): use correct queue and + limit wakeups. [Bug #9343][ruby-core:60517] + * test/thread/test_queue.rb (test_sized_queue_assign_max): + test for bug + Thu Feb 6 07:18:01 2014 Eric Hodel <drbrain@s...> * lib/rubygems: Update to RubyGems 2.2.2. Complete history at: Index: ext/thread/thread.c =================================================================== --- ext/thread/thread.c (revision 44851) +++ ext/thread/thread.c (revision 44852) @@ -437,7 +437,7 @@ rb_szqueue_max_set(VALUE self, VALUE vma https://github.com/ruby/ruby/blob/trunk/ext/thread/thread.c#L437 diff = max - GET_SZQUEUE_ULONGMAX(self); } RSTRUCT_SET(self, SZQUEUE_MAX, vmax); - while (diff > 0 && !NIL_P(t = rb_ary_shift(GET_QUEUE_QUE(self)))) { + while (diff-- > 0 && !NIL_P(t = rb_ary_shift(GET_SZQUEUE_WAITERS(self)))) { rb_thread_wakeup_alive(t); } return vmax; Index: test/thread/test_queue.rb =================================================================== --- test/thread/test_queue.rb (revision 44851) +++ test/thread/test_queue.rb (revision 44852) @@ -55,6 +55,13 @@ class TestQueue < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/thread/test_queue.rb#L55 assert_equal(1, q.max) assert_raise(ArgumentError) { q.max = -1 } assert_equal(1, q.max) + + before = q.max + q.max.times { q << 1 } + t1 = Thread.new { q << 1 } + sleep 0.01 until t1.stop? + q.max = q.max + 1 + assert_equal before + 1, q.max end def test_queue_pop_interrupt -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/