Project

General

Profile

Bug #7100 » webrick-dont-use-ipv4-mapped-ipv6-address.patch

akr (Akira Tanaka), 11/07/2012 07:19 PM

View differences:

lib/webrick/utils.rb (working copy)
72 72
      unless port
73 73
        raise ArgumentError, "must specify port"
74 74
      end
75
      res = Socket::getaddrinfo(address, port,
76
                                Socket::AF_UNSPEC,   # address family
77
                                Socket::SOCK_STREAM, # socket type
78
                                0,                   # protocol
79
                                Socket::AI_PASSIVE)  # flag
80
      last_error = nil
81
      sockets = []
82
      res.each{|ai|
83
        begin
84
          logger.debug("TCPServer.new(#{ai[3]}, #{port})") if logger
85
          sock = TCPServer.new(ai[3], port)
86
          port = sock.addr[1] if port == 0
87
          Utils::set_close_on_exec(sock)
88
          sockets << sock
89
        rescue => ex
90
          logger.warn("TCPServer Error: #{ex}") if logger
91
          last_error  = ex
92
        end
75
      sockets = Socket.tcp_server_sockets(address, port)
76
      sockets = sockets.map {|s|
77
        s.autoclose = false
78
        TCPServer.for_fd(s.fileno)
93 79
      }
94
      raise last_error if sockets.empty?
95 80
      return sockets
96 81
    end
97 82
    module_function :create_listeners