mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
beb59c3b45
Try to fix infrequent error: https://rubyci.org/logs/rubyci.s3.amazonaws.com/solaris10-sunc/ruby-master/log/20200108T010004Z.fail.html.gz ``` 1) Error: DRbTests::TestDRbSSLCore#test_02_basic_object: RangeError: "348" is recycled object (drbssl://localhost:58371) /export/home/users/chkbuild/cb-sunc/tmp/build/20200108T010004Z/ruby/lib/drb/drb.rb:366:in `_id2ref' (drbssl://localhost:58371) /export/home/users/chkbuild/cb-sunc/tmp/build/20200108T010004Z/ruby/lib/drb/drb.rb:366:in `to_obj' (drbssl://localhost:58371) /export/home/users/chkbuild/cb-sunc/tmp/build/20200108T010004Z/ruby/lib/drb/drb.rb:1537:in `to_obj' (drbssl://localhost:58371) /export/home/users/chkbuild/cb-sunc/tmp/build/20200108T010004Z/ruby/lib/drb/drb.rb:1856:in `to_obj' (drbssl://localhost:58371) /export/home/users/chkbuild/cb-sunc/tmp/build/20200108T010004Z/ruby/lib/drb/drb.rb:620:in `recv_request' (drbssl://localhost:58371) /export/home/users/chkbuild/cb-sunc/tmp/build/20200108T010004Z/ruby/lib/drb/drb.rb:931:in `recv_request' (drbssl://localhost:58371) /export/home/users/chkbuild/cb-sunc/tmp/build/20200108T010004Z/ruby/lib/drb/drb.rb:1665:in `init_with_client' (drbssl://localhost:58371) /export/home/users/chkbuild/cb-sunc/tmp/build/20200108T010004Z/ruby/lib/drb/drb.rb:1677:in `setup_message' (drbssl://localhost:58371) /export/home/users/chkbuild/cb-sunc/tmp/build/20200108T010004Z/ruby/lib/drb/drb.rb:1641:in `perform' (drbssl://localhost:58371) /export/home/users/chkbuild/cb-sunc/tmp/build/20200108T010004Z/ruby/lib/drb/drb.rb:1734:in `block (2 levels) in main_loop' (drbssl://localhost:58371) /export/home/users/chkbuild/cb-sunc/tmp/build/20200108T010004Z/ruby/lib/drb/drb.rb:1730:in `loop' (drbssl://localhost:58371) /export/home/users/chkbuild/cb-sunc/tmp/build/20200108T010004Z/ruby/lib/drb/drb.rb:1730:in `block in main_loop' /export/home/users/chkbuild/cb-sunc/tmp/build/20200108T010004Z/ruby/test/drb/drbtest.rb:163:in `test_02_basic_object' ```
177 lines
2.4 KiB
Ruby
177 lines
2.4 KiB
Ruby
# frozen_string_literal: false
|
|
require 'drb/drb'
|
|
require 'drb/extserv'
|
|
require 'timeout'
|
|
|
|
module DRbTests
|
|
|
|
class XArray < Array
|
|
def initialize(ary)
|
|
ary.each do |x|
|
|
self.push(x)
|
|
end
|
|
end
|
|
end
|
|
|
|
class XArray2 < XArray
|
|
include DRbUndumped
|
|
end
|
|
|
|
class Unknown2
|
|
def initialize
|
|
@foo = 'unknown2'
|
|
end
|
|
end
|
|
|
|
class DRbEx
|
|
include DRbUndumped
|
|
|
|
class FooBar
|
|
def initialize
|
|
@foo = 'bar'
|
|
end
|
|
end
|
|
|
|
class UError < RuntimeError; end
|
|
|
|
def initialize
|
|
@xary2_hash = nil
|
|
@hash = nil
|
|
@hello = 'hello'
|
|
end
|
|
attr_reader :hello
|
|
|
|
def sample(a, b, c)
|
|
a.to_i + b.to_i + c.to_i
|
|
end
|
|
|
|
def sum(*a)
|
|
s = 0
|
|
a.each do |e|
|
|
s += e.to_i
|
|
end
|
|
s
|
|
end
|
|
|
|
def do_timeout(n)
|
|
Timeout.timeout(0.1) do
|
|
n.sleep(2)
|
|
end
|
|
end
|
|
|
|
def unknown_module
|
|
FooBar.new
|
|
end
|
|
|
|
class BO < ::BasicObject
|
|
def foo; 1 end
|
|
protected def prot; 2; end
|
|
private def priv; 3; end
|
|
end
|
|
def basic_object
|
|
@basic_object = BO.new
|
|
end
|
|
|
|
def unknown_class
|
|
Unknown2.new
|
|
end
|
|
|
|
def unknown_error
|
|
raise UError
|
|
end
|
|
|
|
def remote_no_method_error
|
|
invoke_no_method(self)
|
|
end
|
|
|
|
def test_yield
|
|
yield
|
|
yield([])
|
|
yield(*[])
|
|
end
|
|
|
|
def echo_yield(*arg)
|
|
yield(*arg)
|
|
nil
|
|
end
|
|
|
|
def echo_yield_0
|
|
yield
|
|
nil
|
|
end
|
|
|
|
def echo_yield_1(one)
|
|
yield(one)
|
|
nil
|
|
end
|
|
|
|
def echo_yield_2(one, two)
|
|
yield(one, two)
|
|
nil
|
|
end
|
|
|
|
def xarray_each
|
|
xary = [XArray.new([0])]
|
|
xary.each do |x|
|
|
yield(x)
|
|
end
|
|
nil
|
|
end
|
|
|
|
def xarray2_hash
|
|
unless @xary2_hash
|
|
@xary2_hash = { "a" => XArray2.new([0]), "b" => XArray2.new([1]) }
|
|
end
|
|
DRbObject.new(@xary2_hash)
|
|
end
|
|
|
|
def simple_hash
|
|
unless @hash
|
|
@hash = { 'a'=>:a, 'b'=>:b }
|
|
end
|
|
DRbObject.new(@hash)
|
|
end
|
|
|
|
def [](key)
|
|
key.to_s
|
|
end
|
|
|
|
def to_a
|
|
[self]
|
|
end
|
|
|
|
def method_missing(msg, *a, &b)
|
|
if msg == :missing
|
|
return true
|
|
else
|
|
super(msg, *a, &b)
|
|
end
|
|
end
|
|
|
|
private
|
|
def call_private_method
|
|
true
|
|
end
|
|
|
|
protected
|
|
def call_protected_method
|
|
true
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
if __FILE__ == $0
|
|
def ARGV.shift
|
|
it = super()
|
|
raise "usage: #{$0} <manager-uri> <name>" unless it
|
|
it
|
|
end
|
|
|
|
DRb::DRbServer.default_argc_limit(8)
|
|
DRb::DRbServer.default_load_limit(4096)
|
|
DRb.start_service('druby://localhost:0', DRbTests::DRbEx.new)
|
|
es = DRb::ExtServ.new(ARGV.shift, ARGV.shift)
|
|
DRb.thread.join
|
|
es.stop_service if es.alive?
|
|
end
|