diff options
author | seki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-01 14:52:33 +0000 |
---|---|---|
committer | seki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-01 14:52:33 +0000 |
commit | a6157194a63e8e254f94b4ee3b7c9184b34aa3fc (patch) | |
tree | 05f082fdf78db0aa1c2bac0858d5ab2b9b6be021 /lib/drb | |
parent | 93f00244c51d48b6c18048d7ab4224eb01c8cb36 (diff) |
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
Diffstat (limited to 'lib/drb')
-rw-r--r-- | lib/drb/drb.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb index 25fbb3f788..2fa15445ef 100644 --- a/lib/drb/drb.rb +++ b/lib/drb/drb.rb @@ -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 |