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

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2015-04-15 20:11:23 +00:00
parent dc3c2496bb
commit b90ad8a2f6
3 changed files with 10 additions and 3 deletions

View file

@ -1,3 +1,9 @@
Thu Apr 16 05:09:36 2015 Eric Wong <e@80x24.org>
* 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@atdot.net>
* vm_trace.c (rb_tracepoint_new): fix documentation.

View file

@ -309,7 +309,7 @@ class Net::HTTPGenericRequest
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

View file

@ -20,6 +20,7 @@
require 'socket'
require 'timeout'
require 'io/wait'
module Net # :nodoc:
@ -153,12 +154,12 @@ module Net # :nodoc:
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