mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
72d18038d9
commit
eef4a3cd72
4 changed files with 33 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Wed Feb 5 23:57:05 2014 Charlie Somerville <charliesome@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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@ruby-lang.org>
|
Wed Feb 5 23:43:30 2014 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* hash.c (rb_objid_hash): should return `long'. brushup r44534.
|
* hash.c (rb_objid_hash): should return `long'. brushup r44534.
|
||||||
|
|
|
@ -459,7 +459,7 @@ static VALUE
|
||||||
rb_szqueue_push(VALUE self, VALUE obj)
|
rb_szqueue_push(VALUE self, VALUE obj)
|
||||||
{
|
{
|
||||||
struct waiting_delete args;
|
struct waiting_delete args;
|
||||||
args.waiting = GET_QUEUE_WAITERS(self);
|
args.waiting = GET_SZQUEUE_WAITERS(self);
|
||||||
args.th = rb_thread_current();
|
args.th = rb_thread_current();
|
||||||
|
|
||||||
while (queue_length(self) >= GET_SZQUEUE_ULONGMAX(self)) {
|
while (queue_length(self) >= GET_SZQUEUE_ULONGMAX(self)) {
|
||||||
|
|
|
@ -134,6 +134,29 @@ class TestQueue < Test::Unit::TestCase
|
||||||
assert_same q, retval
|
assert_same q, retval
|
||||||
end
|
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
|
def test_queue_thread_raise
|
||||||
q = Queue.new
|
q = Queue.new
|
||||||
th1 = Thread.new do
|
th1 = Thread.new do
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#define RUBY_VERSION "2.1.1"
|
#define RUBY_VERSION "2.1.1"
|
||||||
#define RUBY_RELEASE_DATE "2014-02-05"
|
#define RUBY_RELEASE_DATE "2014-02-05"
|
||||||
#define RUBY_PATCHLEVEL 22
|
#define RUBY_PATCHLEVEL 23
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2014
|
#define RUBY_RELEASE_YEAR 2014
|
||||||
#define RUBY_RELEASE_MONTH 2
|
#define RUBY_RELEASE_MONTH 2
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue