* lib/webrick/utils.rb: use Socket.tcp_server_sockets to create server

sockets.
  fix [Bug #7100] https://bugs.ruby-lang.org/issues/7100
  reported by sho-h (Sho Hashimoto).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-03-02 08:36:16 +00:00
Родитель e563e6bf10
Коммит b1f493dcd1
2 изменённых файлов: 11 добавлений и 19 удалений

Просмотреть файл

@ -1,3 +1,10 @@
Sat Mar 2 17:34:19 2013 Tanaka Akira <akr@fsij.org>
* lib/webrick/utils.rb: use Socket.tcp_server_sockets to create server
sockets.
fix [Bug #7100] https://bugs.ruby-lang.org/issues/7100
reported by sho-h (Sho Hashimoto).
Sat Mar 2 02:45:00 2013 Zachary Scott <zachary@zacharyscott.net>
* array.c: typo in comment patch by Nami-Doc [Github fixes #253]

Просмотреть файл

@ -72,26 +72,11 @@ module WEBrick
unless port
raise ArgumentError, "must specify port"
end
res = Socket::getaddrinfo(address, port,
Socket::AF_UNSPEC, # address family
Socket::SOCK_STREAM, # socket type
0, # protocol
Socket::AI_PASSIVE) # flag
last_error = nil
sockets = []
res.each{|ai|
begin
logger.debug("TCPServer.new(#{ai[3]}, #{port})") if logger
sock = TCPServer.new(ai[3], port)
port = sock.addr[1] if port == 0
Utils::set_close_on_exec(sock)
sockets << sock
rescue => ex
logger.warn("TCPServer Error: #{ex}") if logger
last_error = ex
end
sockets = Socket.tcp_server_sockets(address, port)
sockets = sockets.map {|s|
s.autoclose = false
TCPServer.for_fd(s.fileno)
}
raise last_error if sockets.empty?
return sockets
end
module_function :create_listeners