stdlib: use IO#wait_*able instead of IO.select when possible
In case a process encounters high-numbered FDs, this allows consistent performance on systems with ppoll support. [ruby-core:35572] * ext/socket/lib/socket.rb (connect_nonblock): use IO#wait_writable * lib/drb/drb.rb (DRB::DRbTCPSocket#alive?): use IO#wait_readable * lib/webrick/httpserver.rb (run): ditto * lib/resolv.rb (request): ditto for single socket case [ruby-core:68943] [Feature #11081] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8e08552ed0
commit
84b012e02a
@ -1,3 +1,11 @@
|
|||||||
|
Thu May 7 05:14:39 2015 Eric Wong <e@80x24.org>
|
||||||
|
|
||||||
|
* ext/socket/lib/socket.rb (connect_nonblock): use IO#wait_writable
|
||||||
|
* lib/drb/drb.rb (DRB::DRbTCPSocket#alive?): use IO#wait_readable
|
||||||
|
* lib/webrick/httpserver.rb (run): ditto
|
||||||
|
* lib/resolv.rb (request): ditto for single socket case
|
||||||
|
[ruby-core:68943] [Feature #11081]
|
||||||
|
|
||||||
Wed May 6 22:49:54 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed May 6 22:49:54 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* vm_eval.c (rb_method_call_status): undefined refined method is
|
* vm_eval.c (rb_method_call_status): undefined refined method is
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
require 'socket.so'
|
require 'socket.so'
|
||||||
|
require 'io/wait'
|
||||||
|
|
||||||
class Addrinfo
|
class Addrinfo
|
||||||
# creates an Addrinfo object from the arguments.
|
# creates an Addrinfo object from the arguments.
|
||||||
@ -54,9 +55,8 @@ class Addrinfo
|
|||||||
when 0 # success or EISCONN, other errors raise
|
when 0 # success or EISCONN, other errors raise
|
||||||
break
|
break
|
||||||
when :wait_writable
|
when :wait_writable
|
||||||
if !IO.select(nil, [sock], nil, timeout)
|
sock.wait_writable(timeout) or
|
||||||
raise Errno::ETIMEDOUT, 'user specified timeout'
|
raise Errno::ETIMEDOUT, 'user specified timeout'
|
||||||
end
|
|
||||||
end while true
|
end while true
|
||||||
else
|
else
|
||||||
sock.connect(self)
|
sock.connect(self)
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
require 'socket'
|
require 'socket'
|
||||||
require 'thread'
|
require 'thread'
|
||||||
require 'fcntl'
|
require 'fcntl'
|
||||||
|
require 'io/wait'
|
||||||
require 'drb/eq'
|
require 'drb/eq'
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -1003,7 +1004,7 @@ module DRb
|
|||||||
# Check to see if this connection is alive.
|
# Check to see if this connection is alive.
|
||||||
def alive?
|
def alive?
|
||||||
return false unless @socket
|
return false unless @socket
|
||||||
if IO.select([@socket], nil, nil, 0)
|
if @socket.to_io.wait_readable(0)
|
||||||
close
|
close
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
require 'socket'
|
require 'socket'
|
||||||
require 'timeout'
|
require 'timeout'
|
||||||
require 'thread'
|
require 'thread'
|
||||||
|
require 'io/wait'
|
||||||
|
|
||||||
begin
|
begin
|
||||||
require 'securerandom'
|
require 'securerandom'
|
||||||
@ -680,7 +681,11 @@ class Resolv
|
|||||||
if timeout <= 0
|
if timeout <= 0
|
||||||
raise ResolvTimeout
|
raise ResolvTimeout
|
||||||
end
|
end
|
||||||
|
if @socks.size == 1
|
||||||
|
select_result = @socks[0].wait_readable(timeout) ? [ @socks ] : nil
|
||||||
|
else
|
||||||
select_result = IO.select(@socks, nil, nil, timeout)
|
select_result = IO.select(@socks, nil, nil, timeout)
|
||||||
|
end
|
||||||
if !select_result
|
if !select_result
|
||||||
after_select = Time.now
|
after_select = Time.now
|
||||||
next if after_select < timelimit
|
next if after_select < timelimit
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#
|
#
|
||||||
# $IPR: httpserver.rb,v 1.63 2002/10/01 17:16:32 gotoyuzo Exp $
|
# $IPR: httpserver.rb,v 1.63 2002/10/01 17:16:32 gotoyuzo Exp $
|
||||||
|
|
||||||
|
require 'io/wait'
|
||||||
require 'webrick/server'
|
require 'webrick/server'
|
||||||
require 'webrick/httputils'
|
require 'webrick/httputils'
|
||||||
require 'webrick/httpstatus'
|
require 'webrick/httpstatus'
|
||||||
@ -72,7 +73,7 @@ module WEBrick
|
|||||||
begin
|
begin
|
||||||
timeout = @config[:RequestTimeout]
|
timeout = @config[:RequestTimeout]
|
||||||
while timeout > 0
|
while timeout > 0
|
||||||
break if IO.select([sock], nil, nil, 0.5)
|
break if sock.to_io.wait_readable(0.5)
|
||||||
break if @status != :Running
|
break if @status != :Running
|
||||||
timeout -= 0.5
|
timeout -= 0.5
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user