Actions
Bug #806
closedNet::Protocol#rbuf_fill is slow
Description
=begin
Net::Protocol#rbuf_fill is slow. We can take advantage of io.read_nonblock and IO.select to deal with timeouts.
I've attached a patch.
=end
Files
Updated by matz (Yukihiro Matsumoto) about 16 years ago
=begin
merged. report if any problem caused by this patch.
=end
Updated by matz (Yukihiro Matsumoto) about 16 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
Applied in changeset r20443.
=end
Updated by bitsweat (Jeremy Daer) almost 16 years ago
=begin
Breaks if the IO doesn't respond to read_nonblock. StringIO, for example. Fall back to sysread in that case:
Index: lib/net/protocol.rb¶
--- lib/net/protocol.rb (revision 22024)
+++ lib/net/protocol.rb (working copy)
@@ -131,14 +131,20 @@
BUFSIZE = 1024 * 16
def rbuf_fill
-
begin
-
@rbuf << @io.read_nonblock(BUFSIZE)
-
rescue Errno::EWOULDBLOCK
-
if IO.select([@io], nil, nil, @read_timeout)
-
retry
-
else
-
raise Timeout::TimeoutError
-
if @io.respond_to?(:read_nonblock)
-
begin
-
@rbuf << @io.read_nonblock(BUFSIZE)
-
rescue Errno::EWOULDBLOCK
-
if IO.select([@io], nil, nil, @read_timeout)
-
retry
-
else
-
raise Timeout::TimeoutError
-
end end
-
else
-
timeout(@read_timeout) do
-
@rbuf << @io.sysread(BUFSIZE)
-
endend end
=end
Updated by matthewford (Matthew Ford) almost 16 years ago
=begin
I can confirm that Jeremy Kemper's patch works for me and that the patch that was applied breaks IO that doesn't respond to read_nonblock.
=end
Actions
Like0
Like0Like0Like0Like0