protocol.rb.patch
| /usr/local/lib/ruby/1.8/net/protocol.rb 2009-06-27 19:40:38.000000000 +0100 | ||
|---|---|---|
| 82 | 82 |
begin |
| 83 | 83 |
while read_bytes + @rbuf.size < len |
| 84 |
dest << (s = rbuf_consume(@rbuf.size))
|
|
| 84 |
dest << (s = rbuf_consume(nil))
|
|
| 85 | 85 |
read_bytes += s.size |
| 86 | 86 |
rbuf_fill |
| ... | ... | |
| 100 | 100 |
begin |
| 101 | 101 |
while true |
| 102 |
dest << (s = rbuf_consume(@rbuf.size))
|
|
| 102 |
dest << (s = rbuf_consume(nil))
|
|
| 103 | 103 |
read_bytes += s.size |
| 104 | 104 |
rbuf_fill |
| ... | ... | |
| 119 | 119 |
rescue EOFError |
| 120 | 120 |
raise unless ignore_eof |
| 121 |
return rbuf_consume(@rbuf.size)
|
|
| 121 |
return rbuf_consume(nil)
|
|
| 122 | 122 |
end |
| 123 | 123 |
end |
| ... | ... | |
| 130 | 130 | |
| 131 | 131 |
def rbuf_fill |
| 132 |
timeout(@read_timeout) {
|
|
| 133 |
@rbuf << @io.sysread(1024) |
|
| 134 |
} |
|
| 132 |
if IO.select( [ @io ], nil, nil, @read_timeout ) |
|
| 133 |
@rbuf << @io.sysread(1024000) |
|
| 134 |
else |
|
| 135 |
raise Timeout::Error, "read timeout" |
|
| 136 |
end |
|
| 135 | 137 |
end |
| 136 | 138 | |
| 137 | 139 |
def rbuf_consume(len) |
| 138 |
s = @rbuf.slice!(0, len) |
|
| 140 |
if len.nil? or @rbuf.size == len |
|
| 141 |
s = @rbuf |
|
| 142 |
@rbuf = '' |
|
| 143 |
else |
|
| 144 |
s = @rbuf.slice!(0, len) |
|
| 145 |
end |
|
| 139 | 146 |
@debug_output << %Q[-> #{s.dump}\n] if @debug_output
|
| 140 | 147 |
s |