Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby27/share/ruby/drb
File: extservm.rb
# frozen_string_literal: false
[0] Fix | Delete
=begin
[1] Fix | Delete
external service manager
[2] Fix | Delete
Copyright (c) 2000 Masatoshi SEKI
[3] Fix | Delete
=end
[4] Fix | Delete
[5] Fix | Delete
require_relative 'drb'
[6] Fix | Delete
require 'monitor'
[7] Fix | Delete
[8] Fix | Delete
module DRb
[9] Fix | Delete
class ExtServManager
[10] Fix | Delete
include DRbUndumped
[11] Fix | Delete
include MonitorMixin
[12] Fix | Delete
[13] Fix | Delete
@@command = {}
[14] Fix | Delete
[15] Fix | Delete
def self.command
[16] Fix | Delete
@@command
[17] Fix | Delete
end
[18] Fix | Delete
[19] Fix | Delete
def self.command=(cmd)
[20] Fix | Delete
@@command = cmd
[21] Fix | Delete
end
[22] Fix | Delete
[23] Fix | Delete
def initialize
[24] Fix | Delete
super()
[25] Fix | Delete
@cond = new_cond
[26] Fix | Delete
@servers = {}
[27] Fix | Delete
@waiting = []
[28] Fix | Delete
@queue = Thread::Queue.new
[29] Fix | Delete
@thread = invoke_thread
[30] Fix | Delete
@uri = nil
[31] Fix | Delete
end
[32] Fix | Delete
attr_accessor :uri
[33] Fix | Delete
[34] Fix | Delete
def service(name)
[35] Fix | Delete
synchronize do
[36] Fix | Delete
while true
[37] Fix | Delete
server = @servers[name]
[38] Fix | Delete
return server if server && server.alive? # server may be `false'
[39] Fix | Delete
invoke_service(name)
[40] Fix | Delete
@cond.wait
[41] Fix | Delete
end
[42] Fix | Delete
end
[43] Fix | Delete
end
[44] Fix | Delete
[45] Fix | Delete
def regist(name, ro)
[46] Fix | Delete
synchronize do
[47] Fix | Delete
@servers[name] = ro
[48] Fix | Delete
@cond.signal
[49] Fix | Delete
end
[50] Fix | Delete
self
[51] Fix | Delete
end
[52] Fix | Delete
[53] Fix | Delete
def unregist(name)
[54] Fix | Delete
synchronize do
[55] Fix | Delete
@servers.delete(name)
[56] Fix | Delete
end
[57] Fix | Delete
end
[58] Fix | Delete
[59] Fix | Delete
private
[60] Fix | Delete
def invoke_thread
[61] Fix | Delete
Thread.new do
[62] Fix | Delete
while name = @queue.pop
[63] Fix | Delete
invoke_service_command(name, @@command[name])
[64] Fix | Delete
end
[65] Fix | Delete
end
[66] Fix | Delete
end
[67] Fix | Delete
[68] Fix | Delete
def invoke_service(name)
[69] Fix | Delete
@queue.push(name)
[70] Fix | Delete
end
[71] Fix | Delete
[72] Fix | Delete
def invoke_service_command(name, command)
[73] Fix | Delete
raise "invalid command. name: #{name}" unless command
[74] Fix | Delete
synchronize do
[75] Fix | Delete
return if @servers.include?(name)
[76] Fix | Delete
@servers[name] = false
[77] Fix | Delete
end
[78] Fix | Delete
uri = @uri || DRb.uri
[79] Fix | Delete
if command.respond_to? :to_ary
[80] Fix | Delete
command = command.to_ary + [uri, name]
[81] Fix | Delete
pid = spawn(*command)
[82] Fix | Delete
else
[83] Fix | Delete
pid = spawn("#{command} #{uri} #{name}")
[84] Fix | Delete
end
[85] Fix | Delete
th = Process.detach(pid)
[86] Fix | Delete
th[:drb_service] = name
[87] Fix | Delete
th
[88] Fix | Delete
end
[89] Fix | Delete
end
[90] Fix | Delete
end
[91] Fix | Delete
[92] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function