From 0a954e9117168f0221b7cfd833b1e2ea6243ba16 Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 11 Feb 2009 07:51:53 +0000 Subject: * 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 --- ext/socket/lib/socket.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/socket/lib/socket.rb b/ext/socket/lib/socket.rb index 0981b12edc..1099b7fd2f 100644 --- a/ext/socket/lib/socket.rb +++ b/ext/socket/lib/socket.rb @@ -607,7 +607,16 @@ class Socket if st && st.socket? && st.owned? File.unlink path 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 # creates a UNIX socket server on _path_. -- cgit v1.2.3