diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-11 07:51:53 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-11 07:51:53 +0000 |
commit | 239763b34265b28057748c120db030bc3576cb8e (patch) | |
tree | c4fca19ab1a781f28f36c12c02c018fece547b3f /ext | |
parent | a5a3502e7537f495a007de32c527b3b0f1fbbf4e (diff) | |
download | ruby-239763b34265b28057748c120db030bc3576cb8e.tar.gz ruby-239763b34265b28057748c120db030bc3576cb8e.tar.xz ruby-239763b34265b28057748c120db030bc3576cb8e.zip |
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@22233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/socket/lib/socket.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ext/socket/lib/socket.rb b/ext/socket/lib/socket.rb index 0981b12ed..1099b7fd2 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_. |