summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-11 07:54:52 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-11 07:54:52 +0000
commit3f0d724dc36df47e4b262f5c37f6690c2832277e (patch)
tree2f4f511766b585ef00951051bebcedc5c94d2164
parent0a954e9117168f0221b7cfd833b1e2ea6243ba16 (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--ext/socket/lib/socket.rb1
-rw-r--r--test/socket/test_unix.rb3
3 files changed, 9 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 4af8b7d..df1fb46 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* ext/socket/lib/socket.rb (Socket.unix_server_socket): call the block
diff --git a/ext/socket/lib/socket.rb b/ext/socket/lib/socket.rb
index 1099b7f..adc2814 100644
--- a/ext/socket/lib/socket.rb
+++ b/ext/socket/lib/socket.rb
@@ -612,6 +612,7 @@ class Socket
begin
yield s
ensure
+ s.close if !s.closed?
File.unlink path
end
else
diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb
index 2b1f4de..6e822db 100644
--- a/test/socket/test_unix.rb
+++ b/test/socket/test_unix.rb
@@ -299,10 +299,13 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
def test_unix_server_socket
Dir.mktmpdir {|d|
path = "#{d}/sock"
+ s0 = nil
Socket.unix_server_socket(path) {|s|
assert_equal(path, s.local_address.unix_path)
assert(File.socket?(path))
+ s0 = s
}
+ assert(s0.closed?)
assert_raise(Errno::ENOENT) { File.stat path }
}
end