ruby-changes:2310
From: ko1@a...
Date: 1 Nov 2007 23:54:56 +0900
Subject: [ruby-changes:2310] seki - Ruby:r13801 (ruby_1_8): Improving with multiple network interface.
seki 2007-11-01 23:52:33 +0900 (Thu, 01 Nov 2007)
New Revision: 13801
Modified files:
branches/ruby_1_8/ChangeLog
branches/ruby_1_8/lib/drb/drb.rb
branches/ruby_1_8/test/drb/drbtest.rb
Log:
Improving with multiple network interface.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?r1=13801&r2=13800
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/lib/drb/drb.rb?r1=13801&r2=13800
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/test/drb/drbtest.rb?r1=13801&r2=13800
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog (revision 13800)
+++ ruby_1_8/ChangeLog (revision 13801)
@@ -1,3 +1,10 @@
+Thu Nov 1 23:47:43 2007 Masatoshi SEKI <m_seki@m...>
+
+ * 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@r...>
* numeric.c (fix_pow): returns 1.0 for 0**0.0.
Index: ruby_1_8/lib/drb/drb.rb
===================================================================
--- ruby_1_8/lib/drb/drb.rb (revision 13800)
+++ ruby_1_8/lib/drb/drb.rb (revision 13801)
@@ -858,6 +858,7 @@
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 @@
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 @@
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 @@
#
# 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
Index: ruby_1_8/test/drb/drbtest.rb
===================================================================
--- ruby_1_8/test/drb/drbtest.rb (revision 13800)
+++ ruby_1_8/test/drb/drbtest.rb (revision 13801)
@@ -22,7 +22,7 @@
%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
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml