[前][次][番号順一覧][スレッド一覧]

ruby-changes:20865

From: yugui <ko1@a...>
Date: Thu, 11 Aug 2011 09:38:45 +0900 (JST)
Subject: [ruby-changes:20865] yugui:r32912 (ruby_1_9_2): merges r32254 from trunk into ruby_1_9_2.

yugui	2011-08-11 09:37:58 +0900 (Thu, 11 Aug 2011)

  New Revision: 32912

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32912

  Log:
    merges r32254 from trunk into ruby_1_9_2.
    --
    fix [Bug #4409]. add DRbServer#here?

  Added files:
    branches/ruby_1_9_2/test/drb/ut_eq.rb
  Modified files:
    branches/ruby_1_9_2/ChangeLog
    branches/ruby_1_9_2/lib/drb/drb.rb
    branches/ruby_1_9_2/test/drb/drbtest.rb
    branches/ruby_1_9_2/test/drb/test_drb.rb
    branches/ruby_1_9_2/version.h

Index: ruby_1_9_2/ChangeLog
===================================================================
--- ruby_1_9_2/ChangeLog	(revision 32911)
+++ ruby_1_9_2/ChangeLog	(revision 32912)
@@ -1,3 +1,13 @@
+Tue Jun 28 00:14:13 2011  Masatoshi SEKI  <m_seki@m...>
+
+	* lib/drb/drb.rb: fix [Bug #4409]. add DRbServer#here?.
+
+	* test/drb/test_drb.rb: ditto.
+
+	* test/drb/drbtest.rb: ditto.
+
+	* test/drb/ut_eq.rb: ditto.
+
 Tue Jun 28 00:08:43 2011  Keiju Ishitsuka  <keiju@i...>
 
 	* lib/irb/workspace.rb: fix BUG#4793.
Index: ruby_1_9_2/lib/drb/drb.rb
===================================================================
--- ruby_1_9_2/lib/drb/drb.rb	(revision 32911)
+++ ruby_1_9_2/lib/drb/drb.rb	(revision 32912)
@@ -1341,6 +1341,7 @@
 
       @protocol = DRbProtocol.open_server(uri, @config)
       @uri = @protocol.uri
+      @exported_uri = [@uri]
 
       @front = front
       @idconv = @config[:idconv]
@@ -1387,6 +1388,10 @@
     def alive?
       @thread.alive?
     end
+    
+    def here?(uri)
+      @exported_uri.include?(uri)
+    end
 
     # Stop this server.
     def stop_service
@@ -1585,6 +1590,10 @@
 	@grp.add Thread.current
 	Thread.current['DRb'] = { 'client' => client ,
 	                          'server' => self }
+        DRb.mutex.synchronize do
+          client_uri = client.uri
+          @exported_uri << client_uri unless @exported_uri.include?(client_uri)
+        end
 	loop do
 	  begin
 	    succ = false
@@ -1681,7 +1690,8 @@
 
   # Is +uri+ the URI for the current local server?
   def here?(uri)
-    (current_server.uri rescue nil) == uri
+    current_server.here?(uri) rescue false
+    # (current_server.uri rescue nil) == uri
   end
   module_function :here?
 
Index: ruby_1_9_2/version.h
===================================================================
--- ruby_1_9_2/version.h	(revision 32911)
+++ ruby_1_9_2/version.h	(revision 32912)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.2"
-#define RUBY_PATCHLEVEL 297
+#define RUBY_PATCHLEVEL 298
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 9
 #define RUBY_VERSION_TEENY 1
Index: ruby_1_9_2/test/drb/ut_eq.rb
===================================================================
--- ruby_1_9_2/test/drb/ut_eq.rb	(revision 0)
+++ ruby_1_9_2/test/drb/ut_eq.rb	(revision 32912)
@@ -0,0 +1,30 @@
+require 'drb/drb'
+require 'drb/extserv'
+
+class Foo
+  include DRbUndumped
+end
+
+class Bar
+  include DRbUndumped
+  def initialize
+    @foo = Foo.new
+  end
+  attr_reader :foo
+  
+  def foo?(foo)
+    @foo == foo
+  end
+end
+
+if __FILE__ == $0
+  def ARGV.shift
+    it = super()
+    raise "usage: #{$0} <uri> <name>" unless it
+    it
+  end
+
+  DRb.start_service('druby://:0', Bar.new)
+  es = DRb::ExtServ.new(ARGV.shift, ARGV.shift)
+  DRb.thread.join
+end
Index: ruby_1_9_2/test/drb/test_drb.rb
===================================================================
--- ruby_1_9_2/test/drb/test_drb.rb	(revision 32911)
+++ ruby_1_9_2/test/drb/test_drb.rb	(revision 32912)
@@ -299,3 +299,19 @@
     assert_kind_of(StandardError, exception)
   end
 end
+
+class TestBug4409 < Test::Unit::TestCase
+  def setup
+    @ext = DRbService.ext_service('ut_eq.rb')
+    @there = @ext.front
+  end
+
+  def teardown
+    @ext.stop_service if @ext
+  end
+  
+  def test_bug4409
+    foo = @there.foo
+    assert(@there.foo?(foo))
+  end
+end
Index: ruby_1_9_2/test/drb/drbtest.rb
===================================================================
--- ruby_1_9_2/test/drb/drbtest.rb	(revision 32911)
+++ ruby_1_9_2/test/drb/drbtest.rb	(revision 32912)
@@ -14,7 +14,7 @@
     DRb::ExtServManager.command[nm] = "#{@@ruby} \"#{dir}/#{nm}\""
   end
 
-  %w(ut_drb.rb ut_array.rb ut_port.rb ut_large.rb ut_safe1.rb ut_eval.rb).each do |nm|
+  %w(ut_drb.rb ut_array.rb ut_port.rb ut_large.rb ut_safe1.rb ut_eval.rb ut_eq.rb).each do |nm|
     add_service_command(nm)
   end
   @server = @@server = DRb::DRbServer.new('druby://localhost:0', @@manager, {})

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]