Project

General

Profile

Bug #1696 » protocol.rb.patch

patch for select timeout + 1M sysread + slice bypass - steveh (Steven Hartland), 06/28/2009 03:47 AM

View differences:

/usr/local/lib/ruby/1.8/net/protocol.rb 2009-06-27 19:40:38.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
@rbuf = ''
else
s = @rbuf.slice!(0, len)
end
@debug_output << %Q[-> #{s.dump}\n] if @debug_output
s
(2-2/2)