Project

General

Profile

Actions

Bug #1245

closed

SizedQueue can be pushed over its limit

Added by mame (Yusuke Endoh) over 16 years ago. Updated about 14 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
Backport:
[ruby-dev:38135]

Description

=begin
遠藤です。

SizedQueue のリミットの判定が間違っています。

$ ./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>

次回のパッチリリースに含めるべきだと思います。

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
    

--
Yusuke ENDOH
=end

Actions #1

Updated by mame (Yusuke Endoh) over 16 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r22765.
=end

Actions

Also available in: Atom PDF

Like0
Like0