Bug #1696 » protocol.rb.patch
/usr/local/lib/ruby/1.8/net/protocol.rb 2009-06-27 17:03:41.000000000 +0100 | ||
---|---|---|
begin
|
||
while read_bytes + @rbuf.size < len
|
||
dest << (s = rbuf_consume(@rbuf.size))
|
||
dest << (s = rbuf_consume(nil))
|
||
read_bytes += s.size
|
||
rbuf_fill
|
||
... | ... | |
begin
|
||
while true
|
||
dest << (s = rbuf_consume(@rbuf.size))
|
||
dest << (s = rbuf_consume(nil))
|
||
read_bytes += s.size
|
||
rbuf_fill
|
||
... | ... | |
rescue EOFError
|
||
raise unless ignore_eof
|
||
return rbuf_consume(@rbuf.size)
|
||
return rbuf_consume(nil)
|
||
end
|
||
end
|
||
... | ... | |
def rbuf_fill
|
||
timeout(@read_timeout) {
|
||
@rbuf << @io.sysread(1024)
|
||
}
|
||
if IO.select( [ @io ], nil, nil, @read_timeout )
|
||
@rbuf << @io.sysread(1024000)
|
||
else
|
||
raise Timeout::Error, "read timeout"
|
||
end
|
||
end
|
||
def rbuf_consume(len)
|
||
s = @rbuf.slice!(0, len)
|
||
if len.nil? or @rbuf.size == len
|
||
s = @rbuf
|
||
else
|
||
s = @rbuf.slice!(0, len)
|
||
end
|
||
@debug_output << %Q[-> #{s.dump}\n] if @debug_output
|
||
s
|