diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | ext/thread/thread.c | 2 | ||||
-rw-r--r-- | test/thread/test_queue.rb | 7 |
3 files changed, 15 insertions, 1 deletions
@@ -1,3 +1,10 @@ +Thu Feb 6 08:23:28 2014 Eric Wong <e@80x24.org> + + * 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@segment7.net> * lib/rubygems: Update to RubyGems 2.2.2. Complete history at: diff --git a/ext/thread/thread.c b/ext/thread/thread.c index befea9ae30..cec8a5b4fa 100644 --- a/ext/thread/thread.c +++ b/ext/thread/thread.c @@ -437,7 +437,7 @@ rb_szqueue_max_set(VALUE self, VALUE vmax) 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; diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb index 07a611ddd2..6d527ad68c 100644 --- a/test/thread/test_queue.rb +++ b/test/thread/test_queue.rb @@ -55,6 +55,13 @@ class TestQueue < Test::Unit::TestCase 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 |