diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-06 20:30:43 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-06 20:30:43 +0000 |
commit | 84b012e02a567f79dc3061cd860be982f95be048 (patch) | |
tree | 78dc35d87193481c49ff2c0ec1c2dd30639867be /lib/resolv.rb | |
parent | 8e08552ed01e827b4e3ca3e0d57695a8737cb394 (diff) |
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
Diffstat (limited to 'lib/resolv.rb')
-rw-r--r-- | lib/resolv.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/resolv.rb b/lib/resolv.rb index e67dff9704..9083bd0b53 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -1,6 +1,7 @@ require 'socket' require 'timeout' require 'thread' +require 'io/wait' begin require 'securerandom' @@ -680,7 +681,11 @@ class Resolv if timeout <= 0 raise ResolvTimeout end - select_result = IO.select(@socks, nil, nil, timeout) + if @socks.size == 1 + select_result = @socks[0].wait_readable(timeout) ? [ @socks ] : nil + else + select_result = IO.select(@socks, nil, nil, timeout) + end if !select_result after_select = Time.now next if after_select < timelimit |