diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-30 00:59:52 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-30 00:59:52 +0000 |
commit | 2dd9d721ed6820a584654c82f4ae1d6331f78a9e (patch) | |
tree | 8727ff66e424d7ae7621a06c7fb7e9c60331fbe9 | |
parent | 3ffa44622db2386727a8e11bb3aeb0385621f9fa (diff) | |
download | ruby-2dd9d721ed6820a584654c82f4ae1d6331f78a9e.tar.gz |
* lib/thread.rb (Queue#pop): fix a race against Thread.wakeup.
Patch by Masaki Matsushita <glass.saga at gmail dot com>
[Bug #5195] [ruby-dev:44400]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/thread.rb | 4 |
2 files changed, 9 insertions, 1 deletions
@@ -1,3 +1,9 @@ +Tue Aug 30 09:57:50 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * lib/thread.rb (Queue#pop): fix a race against Thread.wakeup. + Patch by Masaki Matsushita <glass.saga at gmail dot com> + [Bug #5195] [ruby-dev:44400] + Tue Aug 30 09:48:07 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com> * cont.c (fiber_entry): fix stack allocation failure on Debian diff --git a/lib/thread.rb b/lib/thread.rb index 58c4f6b9e6..09f2d58ecc 100644 --- a/lib/thread.rb +++ b/lib/thread.rb @@ -185,7 +185,9 @@ class Queue while true if @que.empty? raise ThreadError, "queue empty" if non_block - @waiting.push Thread.current + # @waiting.include? check is necessary for avoiding a race against + # Thread.wakeup [Bug 5195] + @waiting.push Thread.current unless @waiting.include?(Thread.current) @mutex.sleep else return @que.shift |