From: Ernest W. Durbin III Date: Fri, 1 Nov 2013 14:12:33 +0000 (-0400) Subject: construct listener_fds Hash in 1.8.6 compatible way X-Git-Tag: v4.7.0~2 X-Git-Url: https://repo.or.cz/w/unicorn.git/commitdiff_plain/7e9e4c740aba24096f768f578779dc1053cb8b70 construct listener_fds Hash in 1.8.6 compatible way This renables the ability for Ruby 1.8.6 environments to perform reexecs [ew: clarified this is for 1.8.6, favor literal {} over Hash.new, tweaked LISTENERS.map => LISTENERS.each, thanks to Hleb Valoshka ] Signed-off-by: Eric Wong --- diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb index 2decd778..402f1339 100644 --- a/lib/unicorn/http_server.rb +++ b/lib/unicorn/http_server.rb @@ -449,13 +449,14 @@ class Unicorn::HttpServer end self.reexec_pid = fork do - listener_fds = Hash[LISTENERS.map do |sock| + listener_fds = {} + LISTENERS.each do |sock| # IO#close_on_exec= will be available on any future version of # Ruby that sets FD_CLOEXEC by default on new file descriptors # ref: http://redmine.ruby-lang.org/issues/5041 sock.close_on_exec = false if sock.respond_to?(:close_on_exec=) - [ sock.fileno, sock ] - end] + listener_fds[sock.fileno] = sock + end ENV['UNICORN_FD'] = listener_fds.keys.join(',') Dir.chdir(START_CTX[:cwd]) cmd = [ START_CTX[0] ].concat(START_CTX[:argv])