1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/net/protocol.rb (Net::BufferedIO#rbuf_fill): use

read_nonblock instead of sysread wrapped by timeout to boost
  performance.  a patch from Aaron Patterson in [ruby-core:20191].
  fix #806

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2008-12-02 06:34:19 +00:00
parent a01e1cfb5b
commit 348d715eaa
2 changed files with 16 additions and 3 deletions

View file

@ -1,3 +1,10 @@
Tue Dec 2 15:31:42 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/net/protocol.rb (Net::BufferedIO#rbuf_fill): use
read_nonblock instead of sysread wrapped by timeout to boost
performance. a patch from Aaron Patterson in [ruby-core:20191].
fix #806
Mon Dec 1 23:23:52 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
* set 1.9.1-p5000 into version number. [ruby-dev:36998]

View file

@ -131,9 +131,15 @@ module Net # :nodoc:
BUFSIZE = 1024 * 16
def rbuf_fill
timeout(@read_timeout) {
@rbuf << @io.sysread(BUFSIZE)
}
begin
@rbuf << @io.read_nonblock(BUFSIZE)
rescue Errno::EWOULDBLOCK
if IO.select([@io], nil, nil, @read_timeout)
@rbuf << @io.read_nonblock(BUFSIZE)
else
raise Timeout::TimeoutError
end
end
end
def rbuf_consume(len)