зеркало из https://github.com/github/ruby.git
changed default binded address family to use an available address family of host name. [druby-ja:101]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
52d91fa402
Коммит
8a92fc9709
|
@ -1,3 +1,10 @@
|
|||
Thu Dec 16 00:43:29 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
|
||||
|
||||
* lib/drb/drb.rb: changed default binded address family to use an
|
||||
available address family of host name. [druby-ja:101]
|
||||
|
||||
* lib/drb/ssl.rb: ditto
|
||||
|
||||
Wed Dec 15 17:47:17 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||
|
||||
* lib/webrick/server.rb (WEBrick::GenericServer#start_thread):
|
||||
|
|
|
@ -815,14 +815,40 @@ module DRb
|
|||
self.new(uri, soc, config)
|
||||
end
|
||||
|
||||
def self.getservername
|
||||
host = Socket::gethostname
|
||||
begin
|
||||
Socket::gethostbyname(host)[0]
|
||||
rescue
|
||||
host
|
||||
end
|
||||
end
|
||||
|
||||
def self.open_server_inaddr_any(host, port)
|
||||
infos = Socket::getaddrinfo(host, nil,
|
||||
Socket::AF_UNSPEC,
|
||||
Socket::SOCK_STREAM,
|
||||
0,
|
||||
Socket::AI_PASSIVE)
|
||||
family = infos.collect { |af, *_| af }.uniq
|
||||
case family
|
||||
when ['AF_INET']
|
||||
return TCPServer.open('0.0.0.0', port)
|
||||
when ['AF_INET6']
|
||||
return TCPServer.open('::', port)
|
||||
else
|
||||
return TCPServer.open(port)
|
||||
end
|
||||
end
|
||||
|
||||
# Open a server listening for connections at +uri+ using
|
||||
# configuration +config+.
|
||||
def self.open_server(uri, config)
|
||||
uri = 'druby://:0' unless uri
|
||||
host, port, opt = parse_uri(uri)
|
||||
if host.size == 0
|
||||
soc = TCPServer.open(port)
|
||||
host = Socket.gethostname
|
||||
host = getservername
|
||||
soc = open_server_inaddr_any(host, port)
|
||||
else
|
||||
soc = TCPServer.open(host, port)
|
||||
end
|
||||
|
|
|
@ -136,8 +136,8 @@ module DRb
|
|||
uri = 'drbssl://:0' unless uri
|
||||
host, port, opt = parse_uri(uri)
|
||||
if host.size == 0
|
||||
soc = TCPServer.open(port)
|
||||
host = Socket.gethostname
|
||||
host = getservername
|
||||
soc = open_server_inaddr_any(host, port)
|
||||
else
|
||||
soc = TCPServer.open(host, port)
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче