[前][次][番号順一覧][スレッド一覧]

ruby-changes:27499

From: akr <ko1@a...>
Date: Sat, 2 Mar 2013 17:41:30 +0900 (JST)
Subject: [ruby-changes:27499] akr:r39551 (trunk): * lib/webrick/utils.rb: use Socket.tcp_server_sockets to create server

akr	2013-03-02 17:36:16 +0900 (Sat, 02 Mar 2013)

  New Revision: 39551

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39551

  Log:
    * 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).

  Modified files:
    trunk/ChangeLog
    trunk/lib/webrick/utils.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39550)
+++ ChangeLog	(revision 39551)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Mar  2 17:34:19 2013  Tanaka Akira  <akr@f...>
+
+	* 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@z...>
 
 	* array.c: typo in comment patch by Nami-Doc [Github fixes #253]
Index: lib/webrick/utils.rb
===================================================================
--- lib/webrick/utils.rb	(revision 39550)
+++ lib/webrick/utils.rb	(revision 39551)
@@ -72,26 +72,11 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/utils.rb#L72
       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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]