1
0
Fork 0
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:
seki 2007-11-01 14:52:33 +00:00
parent 93f00244c5
commit a6157194a6
3 changed files with 22 additions and 2 deletions

View file

@ -1,3 +1,10 @@
Thu Nov 1 23:47:43 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/drb.rb (DRbTCPSocket): Improving with multiple network
interface.
* test/drb/drbtest.rb: ditto.
Fri Oct 26 17:14:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (fix_pow): returns 1.0 for 0**0.0.

View file

@ -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

View file

@ -22,7 +22,7 @@ class DRbService
%w(ut_drb.rb ut_array.rb ut_port.rb ut_large.rb ut_safe1.rb ut_eval.rb).each do |nm|
add_service_command(nm)
end
@server = @@server = DRb::DRbServer.new(nil, @@manager, {})
@server = @@server = DRb::DRbServer.new('druby://localhost:0', @@manager, {})
@@manager.uri = @@server.uri
def self.manager
@@manager