From 9d92bb90f0d0a317834a51a01c4271f68697f956 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 6 Feb 2009 17:52:05 -0800 Subject: socket: temporary UNIX sockets use ".#{$$}.tmp" Instead of ".#{$$}" as the suffix. This makes it clearer that it's a temporary name and also so we can use per-process sockets to make debugging easier. --- lib/unicorn/socket.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/unicorn/socket.rb b/lib/unicorn/socket.rb index 717c1a0..1f0f03f 100644 --- a/lib/unicorn/socket.rb +++ b/lib/unicorn/socket.rb @@ -46,7 +46,7 @@ class Socket elsif respond_to?(:getsockname) addr = Socket.unpack_sockaddr_un(getsockname) # strip the pid from the temp socket path - addr.gsub!(/\.\d+$/, '') or + addr.gsub!(/\.\d+\.tmp$/, '') or raise ArgumentError, "PID not found in path: #{addr}" else raise ArgumentError, "could not determine unicorn_addr for #{self}" @@ -62,7 +62,7 @@ class Socket # atomically replace and start listening for new connections. def unicorn_server_new(address = '0.0.0.0:8080', backlog = 1024) domain, bind_addr = if address[0..0] == "/" - [ AF_UNIX, pack_sockaddr_un("#{address}.#{$$}") ] + [ AF_UNIX, pack_sockaddr_un("#{address}.#{$$}.tmp") ] elsif address =~ /^(\d+\.\d+\.\d+\.\d+):(\d+)$/ [ AF_INET, pack_sockaddr_in($2.to_i, $1) ] end @@ -73,7 +73,7 @@ class Socket s.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined?(Fcntl::FD_CLOEXEC) # atomically replace existing domain socket - File.rename("#{address}.#{$$}", address) if domain == AF_UNIX + File.rename("#{address}.#{$$}.tmp", address) if domain == AF_UNIX s end -- cgit v1.2.3-24-ge0c7