fix [Bug #4409]. add DRbServer#here?
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
eda3f1be20
commit
190bc7ae0e
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
Tue Jun 28 00:14:13 2011 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
|
||||||
|
|
||||||
|
* 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@ishitsuka.com>
|
Tue Jun 28 00:08:43 2011 Keiju Ishitsuka <keiju@ishitsuka.com>
|
||||||
|
|
||||||
* lib/irb/workspace.rb: fix BUG#4793.
|
* lib/irb/workspace.rb: fix BUG#4793.
|
||||||
|
@ -1341,6 +1341,7 @@ module DRb
|
|||||||
|
|
||||||
@protocol = DRbProtocol.open_server(uri, @config)
|
@protocol = DRbProtocol.open_server(uri, @config)
|
||||||
@uri = @protocol.uri
|
@uri = @protocol.uri
|
||||||
|
@exported_uri = [@uri]
|
||||||
|
|
||||||
@front = front
|
@front = front
|
||||||
@idconv = @config[:idconv]
|
@idconv = @config[:idconv]
|
||||||
@ -1387,6 +1388,10 @@ module DRb
|
|||||||
def alive?
|
def alive?
|
||||||
@thread.alive?
|
@thread.alive?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def here?(uri)
|
||||||
|
@exported_uri.include?(uri)
|
||||||
|
end
|
||||||
|
|
||||||
# Stop this server.
|
# Stop this server.
|
||||||
def stop_service
|
def stop_service
|
||||||
@ -1570,6 +1575,10 @@ module DRb
|
|||||||
@grp.add Thread.current
|
@grp.add Thread.current
|
||||||
Thread.current['DRb'] = { 'client' => client ,
|
Thread.current['DRb'] = { 'client' => client ,
|
||||||
'server' => self }
|
'server' => self }
|
||||||
|
DRb.mutex.synchronize do
|
||||||
|
client_uri = client.uri
|
||||||
|
@exported_uri << client_uri unless @exported_uri.include?(client_uri)
|
||||||
|
end
|
||||||
loop do
|
loop do
|
||||||
begin
|
begin
|
||||||
succ = false
|
succ = false
|
||||||
@ -1666,7 +1675,8 @@ module DRb
|
|||||||
|
|
||||||
# Is +uri+ the URI for the current local server?
|
# Is +uri+ the URI for the current local server?
|
||||||
def here?(uri)
|
def here?(uri)
|
||||||
(current_server.uri rescue nil) == uri
|
current_server.here?(uri) rescue false
|
||||||
|
# (current_server.uri rescue nil) == uri
|
||||||
end
|
end
|
||||||
module_function :here?
|
module_function :here?
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class DRbService
|
|||||||
DRb::ExtServManager.command[nm] = "#{@@ruby} \"#{dir}/#{nm}\""
|
DRb::ExtServManager.command[nm] = "#{@@ruby} \"#{dir}/#{nm}\""
|
||||||
end
|
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)
|
add_service_command(nm)
|
||||||
end
|
end
|
||||||
@server = @@server = DRb::DRbServer.new('druby://localhost:0', @@manager, {})
|
@server = @@server = DRb::DRbServer.new('druby://localhost:0', @@manager, {})
|
||||||
|
@ -299,3 +299,19 @@ class TestDRbLarge < Test::Unit::TestCase
|
|||||||
assert_kind_of(StandardError, exception)
|
assert_kind_of(StandardError, exception)
|
||||||
end
|
end
|
||||||
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
|
||||||
|
30
test/drb/ut_eq.rb
Normal file
30
test/drb/ut_eq.rb
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user