[前][次][番号順一覧][スレッド一覧]

ruby-changes:8907

From: matz <ko1@a...>
Date: Tue, 2 Dec 2008 15:34:36 +0900 (JST)
Subject: [ruby-changes:8907] Ruby:r20443 (trunk): * lib/net/protocol.rb (Net::BufferedIO#rbuf_fill): use

matz	2008-12-02 15:34:19 +0900 (Tue, 02 Dec 2008)

  New Revision: 20443

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20443

  Log:
    * 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

  Modified files:
    trunk/ChangeLog
    trunk/lib/net/protocol.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 20442)
+++ ChangeLog	(revision 20443)
@@ -1,3 +1,10 @@
+Tue Dec  2 15:31:42 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* 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@y...>
 
 	* set 1.9.1-p5000 into version number. [ruby-dev:36998]
Index: lib/net/protocol.rb
===================================================================
--- lib/net/protocol.rb	(revision 20442)
+++ lib/net/protocol.rb	(revision 20443)
@@ -131,9 +131,15 @@
     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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]