mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merged from ruby_1_8 branch.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
44b6b031ba
commit
6591e38016
12 changed files with 95 additions and 85 deletions
24
ChangeLog
24
ChangeLog
|
@ -1,3 +1,27 @@
|
|||
Tue Nov 20 03:24:42 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
|
||||
|
||||
* lib/drb/extservm.rb: merged from ruby_1_8 branch.
|
||||
|
||||
* lib/drb/acl.rb: ditto.
|
||||
|
||||
* lib/drb/ssl.rb: ditto.
|
||||
|
||||
* lib/drb/unix.rb: ditto.
|
||||
|
||||
* lib/drb/drb.rb: ditto.
|
||||
|
||||
* lib/drb/observer.rb: ditto.
|
||||
|
||||
* lib/drb/invokemethod.rb: ditto.
|
||||
|
||||
* test/drb/test_drbssl.rb: ditto.
|
||||
|
||||
* test/drb/test_drb.rb: ditto.
|
||||
|
||||
* test/drb/drbtest.rb: ditto.
|
||||
|
||||
* test/drb/test_drbunix.rb: ditto.
|
||||
|
||||
Tue Nov 20 00:52:46 2007 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* test/fileutils/fileasserts.rb (assert_equal_time): show nsec if
|
||||
|
|
|
@ -13,6 +13,8 @@ class ACL
|
|||
def initialize(str)
|
||||
if str == '*' or str == 'all'
|
||||
@pat = [:all]
|
||||
elsif str.include?('*')
|
||||
@pat = [:name, dot_pat(str)]
|
||||
else
|
||||
begin
|
||||
@pat = [:ip, IPAddr.new(str)]
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
# Copyright (c) 1999-2003 Masatoshi SEKI. You can redistribute it and/or
|
||||
# modify it under the same terms as Ruby.
|
||||
#
|
||||
# Author: Masatoshi SEKI
|
||||
# Author:: Masatoshi SEKI
|
||||
#
|
||||
# Documentation: William Webber (william@williamwebber.com)
|
||||
# Documentation:: William Webber (william@williamwebber.com)
|
||||
#
|
||||
# == Overview
|
||||
#
|
||||
|
@ -578,8 +578,7 @@ module DRb
|
|||
end
|
||||
raise(DRbConnError, 'connection closed') if str.nil?
|
||||
raise(DRbConnError, 'premature marshal format(can\'t read)') if str.size < sz
|
||||
# TODO: YARV doesn't have Thread.exclusive
|
||||
#Thread.exclusive do
|
||||
DRb.mutex.synchronize do
|
||||
begin
|
||||
save = Thread.current[:drb_untaint]
|
||||
Thread.current[:drb_untaint] = []
|
||||
|
@ -592,7 +591,7 @@ module DRb
|
|||
end
|
||||
Thread.current[:drb_untaint] = save
|
||||
end
|
||||
#end
|
||||
end
|
||||
end
|
||||
|
||||
def send_request(stream, ref, msg_id, arg, b) # :nodoc:
|
||||
|
@ -833,7 +832,7 @@ module DRb
|
|||
begin
|
||||
Socket::gethostbyname(host)[0]
|
||||
rescue
|
||||
host
|
||||
'localhost'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -859,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)
|
||||
|
@ -866,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
|
||||
|
@ -946,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.
|
||||
|
@ -973,7 +979,7 @@ module DRb
|
|||
def initialize(option)
|
||||
@option = option.to_s
|
||||
end
|
||||
attr_reader :option
|
||||
attr :option
|
||||
def to_s; @option; end
|
||||
|
||||
def ==(other)
|
||||
|
@ -1497,7 +1503,7 @@ module DRb
|
|||
if $SAFE < @safe_level
|
||||
info = Thread.current['DRb']
|
||||
if @block
|
||||
@result = Thread.new {
|
||||
@result = Thread.new {
|
||||
Thread.current['DRb'] = info
|
||||
$SAFE = @safe_level
|
||||
perform_with_block
|
||||
|
@ -1517,7 +1523,7 @@ module DRb
|
|||
end
|
||||
end
|
||||
@succ = true
|
||||
if @msg_id == :to_ary
|
||||
if @msg_id == :to_ary && @result.class == Array
|
||||
@result = DRbArray.new(@result)
|
||||
end
|
||||
return @succ, @result
|
||||
|
@ -1553,7 +1559,7 @@ module DRb
|
|||
end
|
||||
ary.collect(&@obj)[0]
|
||||
else
|
||||
@obj.send(@msg_id, *@argv)
|
||||
@obj.__send__(@msg_id, *@argv)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1667,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
|
||||
|
@ -1739,13 +1751,18 @@ module DRb
|
|||
end
|
||||
module_function :install_acl
|
||||
|
||||
@mutex = Mutex.new
|
||||
def mutex
|
||||
@mutex
|
||||
end
|
||||
module_function :mutex
|
||||
|
||||
@server = {}
|
||||
def regist_server(server)
|
||||
@server[server.uri] = server
|
||||
# TODO: YARV doesn't have Thread.exclusive
|
||||
#Thread.exclusive do
|
||||
mutex.synchronize do
|
||||
@primary_server = server unless @primary_server
|
||||
#end
|
||||
end
|
||||
end
|
||||
module_function :regist_server
|
||||
|
||||
|
|
|
@ -5,10 +5,12 @@
|
|||
|
||||
require 'drb/drb'
|
||||
require 'thread'
|
||||
require 'monitor'
|
||||
|
||||
module DRb
|
||||
class ExtServManager
|
||||
include DRbUndumped
|
||||
include MonitorMixin
|
||||
|
||||
@@command = {}
|
||||
|
||||
|
@ -21,6 +23,8 @@ module DRb
|
|||
end
|
||||
|
||||
def initialize
|
||||
super()
|
||||
@cond = new_cond
|
||||
@servers = {}
|
||||
@waiting = []
|
||||
@queue = Queue.new
|
||||
|
@ -30,39 +34,28 @@ module DRb
|
|||
attr_accessor :uri
|
||||
|
||||
def service(name)
|
||||
while true
|
||||
server = nil
|
||||
# TODO: YARV doesn't have Thread.exclusive
|
||||
#Thread.exclusive do
|
||||
server = @servers[name] if @servers[name]
|
||||
#end
|
||||
return server if server && server.alive?
|
||||
invoke_service(name)
|
||||
synchronize do
|
||||
while true
|
||||
server = @servers[name]
|
||||
return server if server && server.alive?
|
||||
invoke_service(name)
|
||||
@cond.wait
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def regist(name, ro)
|
||||
ary = nil
|
||||
# TODO: YARV doesn't have Thread.exclusive
|
||||
#Thread.exclusive do
|
||||
@servers[name] = ro
|
||||
ary = @waiting
|
||||
@waiting = []
|
||||
#end
|
||||
ary.each do |th|
|
||||
begin
|
||||
th.run
|
||||
rescue ThreadError
|
||||
end
|
||||
synchronize do
|
||||
@servers[name] = ro
|
||||
@cond.signal
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def unregist(name)
|
||||
# TODO: YARV doesn't have Thread.exclusive
|
||||
#Thread.exclusive do
|
||||
synchronize do
|
||||
@servers.delete(name)
|
||||
#end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -76,22 +69,21 @@ module DRb
|
|||
end
|
||||
|
||||
def invoke_service(name)
|
||||
Thread.critical = true
|
||||
@waiting.push Thread.current
|
||||
@queue.push name
|
||||
Thread.stop
|
||||
@queue.push(name)
|
||||
end
|
||||
|
||||
def invoke_service_command(name, command)
|
||||
raise "invalid command. name: #{name}" unless command
|
||||
# TODO: YARV doesn't have Thread.exclusive
|
||||
#Thread.exclusive do
|
||||
synchronize do
|
||||
return if @servers.include?(name)
|
||||
@servers[name] = false
|
||||
#end
|
||||
end
|
||||
uri = @uri || DRb.uri
|
||||
Process.detach(Process.spawn("#{command} #{uri} #{name}"))
|
||||
true
|
||||
if RUBY_PLATFORM =~ /mswin32/ && /NT/ =~ ENV["OS"]
|
||||
system(%Q'cmd /c start "ruby" /b #{command} #{uri} #{name}')
|
||||
else
|
||||
system("#{command} #{uri} #{name} &")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ module DRb
|
|||
end
|
||||
block_value = @block.call(*x)
|
||||
end
|
||||
|
||||
|
||||
def perform_with_block
|
||||
@obj.__send__(@msg_id, *@argv) do |*x|
|
||||
jump_error = nil
|
||||
|
|
|
@ -6,17 +6,16 @@ module DRb
|
|||
|
||||
def notify_observers(*arg)
|
||||
if defined? @observer_state and @observer_state
|
||||
if defined? @observer_peers
|
||||
@observer_peers.delete_if do |k, v|
|
||||
begin
|
||||
k.send(v, *arg)
|
||||
false
|
||||
rescue
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
@observer_state = false
|
||||
if defined? @observer_peers
|
||||
for i in @observer_peers.dup
|
||||
begin
|
||||
i.update(*arg)
|
||||
rescue
|
||||
delete_observer(i)
|
||||
end
|
||||
end
|
||||
end
|
||||
@observer_state = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -180,7 +180,6 @@ module DRb
|
|||
ssl = @config.accept(soc)
|
||||
self.class.new(uri, ssl, @config, true)
|
||||
rescue OpenSSL::SSL::SSLError
|
||||
soc.close
|
||||
warn("#{__FILE__}:#{__LINE__}: warning: #{$!.message} (#{$!.class})") if @config[:verbose]
|
||||
retry
|
||||
end
|
||||
|
|
|
@ -88,7 +88,7 @@ module DRb
|
|||
public
|
||||
def close
|
||||
return unless @socket
|
||||
path = @socket.path
|
||||
path = @socket.path if @server_mode
|
||||
@socket.close
|
||||
File.unlink(path) if @server_mode
|
||||
@socket = nil
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
__END__
|
||||
require 'test/unit'
|
||||
require 'drb/drb'
|
||||
require 'drb/extservm'
|
||||
|
@ -24,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
|
||||
|
|
|
@ -1,17 +1,5 @@
|
|||
require 'drbtest'
|
||||
|
||||
class TestDRbCore
|
||||
def test_drb
|
||||
flunk("YARV doesn't support drb")
|
||||
end
|
||||
end
|
||||
|
||||
__END__
|
||||
|
||||
end
|
||||
|
||||
__END__
|
||||
|
||||
class TestDRbCore < Test::Unit::TestCase
|
||||
include DRbCore
|
||||
end
|
||||
|
|
|
@ -5,14 +5,8 @@ begin
|
|||
rescue LoadError
|
||||
end
|
||||
|
||||
class TestDRbSSLCore < Test::Unit::TestCase
|
||||
def test_message
|
||||
flunk("YARV doesn't support drb")
|
||||
end
|
||||
end
|
||||
if Object.const_defined?("OpenSSL")
|
||||
|
||||
# TODO: YARV doesn't support drb
|
||||
if false # Object.const_defined?("OpenSSL")
|
||||
|
||||
class DRbSSLService < DRbService
|
||||
%w(ut_drb_drbssl.rb ut_array_drbssl.rb).each do |nm|
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
__END__
|
||||
|
||||
require 'drbtest'
|
||||
|
||||
begin
|
||||
|
|
Loading…
Reference in a new issue