Class: DRb::DRbUNIXSocket
- Inherits:
-
DRbTCPSocket
show all
- Defined in:
- lib/drb/unix.rb
Constant Summary
- Max_try =
10
Instance Attribute Summary
Attributes inherited from DRbTCPSocket
#uri
Class Method Summary
(collapse)
Instance Method Summary
(collapse)
#alive?, getservername, open_server_inaddr_any, #peeraddr, #recv_reply, #recv_request, #send_reply, #send_request, #stream
Constructor Details
- (DRbUNIXSocket) initialize(uri, soc, config = {}, server_mode = false)
A new instance of DRbUNIXSocket
56
57
58
59
60
61
|
# File 'lib/drb/unix.rb', line 56
def initialize(uri, soc, config={}, server_mode = false)
super(uri, soc, config)
set_sockopt(@socket)
@server_mode = server_mode
@acl = nil
end
|
Class Method Details
+ (Object) open(uri, config)
21
22
23
24
25
26
|
# File 'lib/drb/unix.rb', line 21
def self.open(uri, config)
filename, option = parse_uri(uri)
filename.untaint
soc = UNIXSocket.open(filename)
self.new(uri, soc, config)
end
|
+ (Object) open_server(uri, config)
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/drb/unix.rb', line 28
def self.open_server(uri, config)
filename, option = parse_uri(uri)
if filename.size == 0
soc = temp_server
filename = soc.path
uri = 'drbunix:' + soc.path
else
soc = UNIXServer.open(filename)
end
owner = config[:UNIXFileOwner]
group = config[:UNIXFileGroup]
if owner || group
require 'etc'
owner = Etc.getpwnam( owner ).uid if owner
group = Etc.getgrnam( group ).gid if group
File.chown owner, group, filename
end
mode = config[:UNIXFileMode]
File.chmod(mode, filename) if mode
self.new(uri, soc, config, true)
end
|
+ (Object) parse_uri(uri)
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/drb/unix.rb', line 10
def self.parse_uri(uri)
if /^drbunix:(.*?)(\?(.*))?$/ =~ uri
filename = $1
option = $3
[filename, option]
else
raise(DRbBadScheme, uri) unless uri =~ /^drbunix:/
raise(DRbBadURI, 'can\'t parse uri:' + uri)
end
end
|
+ (Object) uri_option(uri, config)
51
52
53
54
|
# File 'lib/drb/unix.rb', line 51
def self.uri_option(uri, config)
filename, option = parse_uri(uri)
return "drbunix:#{filename}", option
end
|
Instance Method Details
97
98
99
100
|
# File 'lib/drb/unix.rb', line 97
def accept
s = @socket.accept
self.class.new(nil, s, @config)
end
|
89
90
91
92
93
94
95
|
# File 'lib/drb/unix.rb', line 89
def close
return unless @socket
path = @socket.path if @server_mode
@socket.close
File.unlink(path) if @server_mode
@socket = nil
end
|
- (Object) set_sockopt(soc)
102
103
104
|
# File 'lib/drb/unix.rb', line 102
def set_sockopt(soc)
soc.fcntl(Fcntl::F_SETFL, Fcntl::FD_CLOEXEC) if defined? Fcntl::FD_CLOEXEC
end
|