Project

General

Profile

Feature #11081 ยป 0001-stdlib-use-IO-wait_-able-instead-of-IO.select-when-p.patch

normalperson (Eric Wong), 04/21/2015 03:52 AM

View differences:

ext/socket/lib/socket.rb
require 'socket.so'
require 'io/wait'
class Addrinfo
# creates an Addrinfo object from the arguments.
......
when 0 # success or EISCONN, other errors raise
break
when :wait_writable
if !IO.select(nil, [sock], nil, timeout)
sock.wait_writable(timeout) or
raise Errno::ETIMEDOUT, 'user specified timeout'
end
end while true
else
sock.connect(self)
lib/drb/drb.rb
require 'socket'
require 'thread'
require 'fcntl'
require 'io/wait'
require 'drb/eq'
#
......
# Check to see if this connection is alive.
def alive?
return false unless @socket
if IO.select([@socket], nil, nil, 0)
if @socket.to_io.wait_readable(0)
close
return false
end
lib/resolv.rb
require 'socket'
require 'timeout'
require 'thread'
require 'io/wait'
begin
require 'securerandom'
......
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
lib/webrick/httpserver.rb
#
# $IPR: httpserver.rb,v 1.63 2002/10/01 17:16:32 gotoyuzo Exp $
require 'io/wait'
require 'webrick/server'
require 'webrick/httputils'
require 'webrick/httpstatus'
......
begin
timeout = @config[:RequestTimeout]
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
timeout -= 0.5
end
-
    (1-1/1)