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): close the
socket when the block exits. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0a954e9117
commit
3f0d724dc3
3 changed files with 9 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Feb 11 16:54:26 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/socket/lib/socket.rb (Socket.unix_server_socket): close the
|
||||||
|
socket when the block exits.
|
||||||
|
|
||||||
Wed Feb 11 16:50:59 2009 Tanaka Akira <akr@fsij.org>
|
Wed Feb 11 16:50:59 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/socket/lib/socket.rb (Socket.unix_server_socket): call the block
|
* ext/socket/lib/socket.rb (Socket.unix_server_socket): call the block
|
||||||
|
|
|
@ -612,6 +612,7 @@ class Socket
|
||||||
begin
|
begin
|
||||||
yield s
|
yield s
|
||||||
ensure
|
ensure
|
||||||
|
s.close if !s.closed?
|
||||||
File.unlink path
|
File.unlink path
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
|
@ -299,10 +299,13 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
|
||||||
def test_unix_server_socket
|
def test_unix_server_socket
|
||||||
Dir.mktmpdir {|d|
|
Dir.mktmpdir {|d|
|
||||||
path = "#{d}/sock"
|
path = "#{d}/sock"
|
||||||
|
s0 = nil
|
||||||
Socket.unix_server_socket(path) {|s|
|
Socket.unix_server_socket(path) {|s|
|
||||||
assert_equal(path, s.local_address.unix_path)
|
assert_equal(path, s.local_address.unix_path)
|
||||||
assert(File.socket?(path))
|
assert(File.socket?(path))
|
||||||
|
s0 = s
|
||||||
}
|
}
|
||||||
|
assert(s0.closed?)
|
||||||
assert_raise(Errno::ENOENT) { File.stat path }
|
assert_raise(Errno::ENOENT) { File.stat path }
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue