about summary refs log tree commit homepage
path: root/lib/unicorn/socket.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/unicorn/socket.rb')
-rw-r--r--lib/unicorn/socket.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/unicorn/socket.rb b/lib/unicorn/socket.rb
index 9519448..4913261 100644
--- a/lib/unicorn/socket.rb
+++ b/lib/unicorn/socket.rb
@@ -62,6 +62,13 @@ module Unicorn
       end
     end
 
+    def destroy_safely(io)
+      if io.respond_to?(:path) && File.stat(io.path).ino == io.stat.ino
+        File.unlink(io.path) rescue nil
+      end
+      io.close rescue nil
+    end
+
     # creates a new server, socket. address may be a HOST:PORT or
     # an absolute path to a UNIX socket.  address can even be a Socket
     # object in which case it is immediately returned