[Bug:trunk] SizedQueue can be pushed over its limit


#1

e$B1sF#$G$9!#e(B

SizedQueue e$B$N%j%_%C%H$NH=Dj$,4V0c$C$F$$$^$9!#e(B

$ ./miniruby -rlib/thread -e ‘q = SizedQueue.new(2); q << 1; q << 1; q
<< 1; p q’
#<SizedQueue:0x81f595c @max=2, @queue_wait=[], @que=[1, 1, 1],
@waiting=[], @mutex=#Mutex:0x81f590c>

e$B<!2s$N%Q%C%A%j%j!<%9$K4^$a$k$Y$-$@$H;W$$$^$9!#e(B

Index: lib/thread.rb

— lib/thread.rb (revision 22764)
+++ lib/thread.rb (working copy)
@@ -292,7 +292,7 @@
t = nil
@mutex.synchronize{
while true

  •    break if @que.length <= @max
    
  •    break if @que.length < @max
       @queue_wait.push Thread.current
       @mutex.sleep
     end

#2

e$B%A%1%C%He(B #1245 e$B$,99?7$5$l$^$7$?!#e(B (by Yusuke E.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

Applied in changeset r22765.

http://redmine.ruby-lang.org/issues/show/1245