[前][次][番号順一覧][スレッド一覧]

ruby-changes:32768

From: naruse <ko1@a...>
Date: Wed, 5 Feb 2014 23:57:17 +0900 (JST)
Subject: [ruby-changes:32768] naruse:r44847 (ruby_2_1): merge revision(s) 44583: [Backport #9302]

naruse	2014-02-05 23:57:11 +0900 (Wed, 05 Feb 2014)

  New Revision: 44847

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44847

  Log:
    merge revision(s) 44583: [Backport #9302]
    
    * ext/thread/thread.c (rb_szqueue_push): check GET_SZQUEUE_WAITERS
      instead of GET_QUEUE_WAITERS to prevent deadlock. Patch by Eric Wong.
      [Bug #9302] [ruby-core:59324]
    
    * test/thread/test_queue.rb: add test

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/ext/thread/thread.c
    branches/ruby_2_1/test/thread/test_queue.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 44846)
+++ ruby_2_1/ChangeLog	(revision 44847)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Wed Feb  5 23:57:05 2014  Charlie Somerville  <charliesome@r...>
+
+	* ext/thread/thread.c (rb_szqueue_push): check GET_SZQUEUE_WAITERS
+	  instead of GET_QUEUE_WAITERS to prevent deadlock. Patch by Eric Wong.
+	  [Bug #9302] [ruby-core:59324]
+
+	* test/thread/test_queue.rb: add test
+
 Wed Feb  5 23:43:30 2014  NAKAMURA Usaku  <usa@r...>
 
 	* hash.c (rb_objid_hash): should return `long'.  brushup r44534.
Index: ruby_2_1/ext/thread/thread.c
===================================================================
--- ruby_2_1/ext/thread/thread.c	(revision 44846)
+++ ruby_2_1/ext/thread/thread.c	(revision 44847)
@@ -459,7 +459,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ext/thread/thread.c#L459
 rb_szqueue_push(VALUE self, VALUE obj)
 {
     struct waiting_delete args;
-    args.waiting = GET_QUEUE_WAITERS(self);
+    args.waiting = GET_SZQUEUE_WAITERS(self);
     args.th      = rb_thread_current();
 
     while (queue_length(self) >= GET_SZQUEUE_ULONGMAX(self)) {
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 44846)
+++ ruby_2_1/version.h	(revision 44847)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.1"
 #define RUBY_RELEASE_DATE "2014-02-05"
-#define RUBY_PATCHLEVEL 22
+#define RUBY_PATCHLEVEL 23
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 2
Index: ruby_2_1/test/thread/test_queue.rb
===================================================================
--- ruby_2_1/test/thread/test_queue.rb	(revision 44846)
+++ ruby_2_1/test/thread/test_queue.rb	(revision 44847)
@@ -134,6 +134,29 @@ class TestQueue < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/thread/test_queue.rb#L134
     assert_same q, retval
   end
 
+  def test_sized_queue_throttle
+    q = SizedQueue.new(1)
+    i = 0
+    consumer = Thread.new do
+      while q.pop
+        i += 1
+        Thread.pass
+      end
+    end
+    nprod = 4
+    npush = 100
+
+    producer = nprod.times.map do
+      Thread.new do
+        npush.times { q.push(true) }
+      end
+    end
+    producer.each(&:join)
+    q.push(nil)
+    consumer.join
+    assert_equal(nprod * npush, i)
+  end
+
   def test_queue_thread_raise
     q = Queue.new
     th1 = Thread.new do

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r44583


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]