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

ruby-changes:38245

From: normal <ko1@a...>
Date: Thu, 16 Apr 2015 05:11:57 +0900 (JST)
Subject: [ruby-changes:38245] normal:r50326 (trunk): lib/net/*: use io/wait methods instead of IO.select

normal	2015-04-16 05:11:23 +0900 (Thu, 16 Apr 2015)

  New Revision: 50326

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

  Log:
    lib/net/*: use io/wait methods instead of IO.select
    
    io/wait is expected to work on any platform where sockets are
    supported.  io/wait methods uses fewer allocations and uses
    ppoll internally under Linux for better performance on
    high-numbered FDs.
    
    [ruby-core:35572] describes the performance advantage of ppoll
    on high-numbered FDs.
    
    * lib/net/protocol.rb (rbuf_fill): use IO#wait_*able
    * lib/net/http/generic_request.rb (wait_for_continue): ditto

  Modified files:
    trunk/ChangeLog
    trunk/lib/net/http/generic_request.rb
    trunk/lib/net/protocol.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50325)
+++ ChangeLog	(revision 50326)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Apr 16 05:09:36 2015  Eric Wong  <e@8...>
+
+	* lib/net/protocol.rb (rbuf_fill): use IO#wait_*able
+	* lib/net/http/generic_request.rb (wait_for_continue): ditto
+	  [ruby-core:68891] [Feature #11056]
+
 Wed Apr 15 18:43:43 2015  Koichi Sasada  <ko1@a...>
 
 	* vm_trace.c (rb_tracepoint_new): fix documentation.
Index: lib/net/http/generic_request.rb
===================================================================
--- lib/net/http/generic_request.rb	(revision 50325)
+++ lib/net/http/generic_request.rb	(revision 50326)
@@ -309,7 +309,7 @@ class Net::HTTPGenericRequest https://github.com/ruby/ruby/blob/trunk/lib/net/http/generic_request.rb#L309
   def wait_for_continue(sock, ver)
     if ver >= '1.1' and @header['expect'] and
         @header['expect'].include?('100-continue')
-      if IO.select([sock.io], nil, nil, sock.continue_timeout)
+      if sock.io.to_io.wait_readable(sock.continue_timeout)
         res = Net::HTTPResponse.read_new(sock)
         unless res.kind_of?(Net::HTTPContinue)
           res.decode_content = @decode_content
Index: lib/net/protocol.rb
===================================================================
--- lib/net/protocol.rb	(revision 50325)
+++ lib/net/protocol.rb	(revision 50326)
@@ -20,6 +20,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/net/protocol.rb#L20
 
 require 'socket'
 require 'timeout'
+require 'io/wait'
 
 module Net # :nodoc:
 
@@ -153,12 +154,12 @@ module Net # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/protocol.rb#L154
       when String
         return @rbuf << rv
       when :wait_readable
-        IO.select([@io], nil, nil, @read_timeout) or raise Net::ReadTimeout
+        @io.to_io.wait_readable(@read_timeout) or raise Net::ReadTimeout
         # continue looping
       when :wait_writable
         # OpenSSL::Buffering#read_nonblock may fail with IO::WaitWritable.
         # http://www.openssl.org/support/faq.html#PROG10
-        IO.select(nil, [@io], nil, @read_timeout) or raise Net::ReadTimeout
+        @io.to_io.wait_writable(@read_timeout) or raise Net::ReadTimeout
         # continue looping
       when nil
         # callers do not care about backtrace, so avoid allocating for it

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

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