diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-03-19 18:07:15 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-03-19 18:07:15 -0700 |
commit | c01c8ccae6a4b500d0aebd385c10f4567d9b0fd3 (patch) | |
tree | b35a9ac2c77caf66af1678a11ba4fbce69b0fda4 | |
parent | 40feaf1c05005153c576396083776c331aa5f01f (diff) | |
download | unicorn-c01c8ccae6a4b500d0aebd385c10f4567d9b0fd3.tar.gz |
This fixes a bug where listener names in the master process would be incorrectly matched with the existing set; causing UNIX sockets to be unbound and rebound; breaking things for child processes. This is a better fit anyways since it's higher level.
-rw-r--r-- | lib/unicorn/configurator.rb | 15 | ||||
-rw-r--r-- | lib/unicorn/socket.rb | 1 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb index ae74c2b..b4713c5 100644 --- a/lib/unicorn/configurator.rb +++ b/lib/unicorn/configurator.rb @@ -173,13 +173,14 @@ module Unicorn # worker processes. For per-worker listeners, see the after_fork example def listeners(addresses) Array === addresses or addresses = Array(addresses) + addresses.map! { |addr| expand_addr(addr) } @set[:listeners] = addresses end # adds an +address+ to the existing listener set def listen(address) @set[:listeners] = [] unless Array === @set[:listeners] - @set[:listeners] << address + @set[:listeners] << expand_addr(address) end # sets the +path+ for the PID file of the unicorn master process @@ -253,5 +254,17 @@ module Unicorn @set[var] = my_proc end + # expands pathnames of sockets if relative to "~" or "~username" + # expands "*:port and ":port" to "0.0.0.0:port" + def expand_addr(address) #:nodoc + return address unless String === address + if address[0..0] == '~' + return File.expand_path(address) + elsif address =~ %r{\A\*?:(\d+)\z} + return "0.0.0.0:#$1" + end + address + end + end end diff --git a/lib/unicorn/socket.rb b/lib/unicorn/socket.rb index d8e44f4..4913261 100644 --- a/lib/unicorn/socket.rb +++ b/lib/unicorn/socket.rb @@ -75,7 +75,6 @@ module Unicorn def bind_listen(address = '0.0.0.0:8080', backlog = 1024) return address unless String === address - address = File.expand_path(address) if address[0..0] == "~" domain, bind_addr = if address[0..0] == "/" if File.exist?(address) if File.socket?(address) |