mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Improving with multiple network interface.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
93f00244c5
commit
a6157194a6
3 changed files with 22 additions and 2 deletions
|
@ -858,6 +858,7 @@ module DRb
|
|||
def self.open_server(uri, config)
|
||||
uri = 'druby://:0' unless uri
|
||||
host, port, opt = parse_uri(uri)
|
||||
config = {:tcp_original_host => host}.update(config)
|
||||
if host.size == 0
|
||||
host = getservername
|
||||
soc = open_server_inaddr_any(host, port)
|
||||
|
@ -865,6 +866,7 @@ module DRb
|
|||
soc = TCPServer.open(host, port)
|
||||
end
|
||||
port = soc.addr[1] if port == 0
|
||||
config[:tcp_port] = port
|
||||
uri = "druby://#{host}:#{port}"
|
||||
self.new(uri, soc, config)
|
||||
end
|
||||
|
@ -945,7 +947,12 @@ module DRb
|
|||
break if (@acl ? @acl.allow_socket?(s) : true)
|
||||
s.close
|
||||
end
|
||||
self.class.new(nil, s, @config)
|
||||
if @config[:tcp_original_host].to_s.size == 0
|
||||
uri = "druby://#{s.addr[3]}:#{@config[:tcp_port]}"
|
||||
else
|
||||
uri = @uri
|
||||
end
|
||||
self.class.new(uri, s, @config)
|
||||
end
|
||||
|
||||
# Check to see if this connection is alive.
|
||||
|
@ -1666,6 +1673,12 @@ module DRb
|
|||
#
|
||||
# This is the URI of the current server. See #current_server.
|
||||
def uri
|
||||
drb = Thread.current['DRb']
|
||||
client = (drb && drb['client'])
|
||||
if client
|
||||
uri = client.uri
|
||||
return uri if uri
|
||||
end
|
||||
current_server.uri
|
||||
end
|
||||
module_function :uri
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue