ruby-changes:21072
From: kosaki <ko1@a...>
Date: Tue, 30 Aug 2011 10:00:05 +0900 (JST)
Subject: [ruby-changes:21072] kosaki:r33121 (trunk): * lib/thread.rb (Queue#pop): fix a race against Thread.wakeup.
kosaki 2011-08-30 09:59:52 +0900 (Tue, 30 Aug 2011) New Revision: 33121 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33121 Log: * 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] Modified files: trunk/ChangeLog trunk/lib/thread.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 33120) +++ ChangeLog (revision 33121) @@ -1,3 +1,9 @@ +Tue Aug 30 09:57:50 2011 KOSAKI Motohiro <kosaki.motohiro@g...> + + * 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@g...> * cont.c (fiber_entry): fix stack allocation failure on Debian Index: lib/thread.rb =================================================================== --- lib/thread.rb (revision 33120) +++ lib/thread.rb (revision 33121) @@ -185,7 +185,9 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/