mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/lib/socket.rb (Socket.unix_server_socket): call the block
if given. remove the socket file when the block exits. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ff955766d4
commit
0a954e9117
3 changed files with 26 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Feb 11 16:50:59 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/socket/lib/socket.rb (Socket.unix_server_socket): call the block
|
||||||
|
if given. remove the socket file when the block exits.
|
||||||
|
|
||||||
Wed Feb 11 16:44:20 2009 Tanaka Akira <akr@fsij.org>
|
Wed Feb 11 16:44:20 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/socket/ancdata.c (ancillary_s_ip_pktinfo): make 3rd argument
|
* ext/socket/ancdata.c (ancillary_s_ip_pktinfo): make 3rd argument
|
||||||
|
|
|
@ -607,7 +607,16 @@ class Socket
|
||||||
if st && st.socket? && st.owned?
|
if st && st.socket? && st.owned?
|
||||||
File.unlink path
|
File.unlink path
|
||||||
end
|
end
|
||||||
Addrinfo.unix(path).listen
|
s = Addrinfo.unix(path).listen
|
||||||
|
if block_given?
|
||||||
|
begin
|
||||||
|
yield s
|
||||||
|
ensure
|
||||||
|
File.unlink path
|
||||||
|
end
|
||||||
|
else
|
||||||
|
s
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# creates a UNIX socket server on _path_.
|
# creates a UNIX socket server on _path_.
|
||||||
|
|
|
@ -296,6 +296,17 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_unix_server_socket
|
||||||
|
Dir.mktmpdir {|d|
|
||||||
|
path = "#{d}/sock"
|
||||||
|
Socket.unix_server_socket(path) {|s|
|
||||||
|
assert_equal(path, s.local_address.unix_path)
|
||||||
|
assert(File.socket?(path))
|
||||||
|
}
|
||||||
|
assert_raise(Errno::ENOENT) { File.stat path }
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def test_getcred_ucred
|
def test_getcred_ucred
|
||||||
return if /linux/ !~ RUBY_PLATFORM
|
return if /linux/ !~ RUBY_PLATFORM
|
||||||
Dir.mktmpdir {|d|
|
Dir.mktmpdir {|d|
|
||||||
|
|
Loading…
Reference in a new issue