construct listener_fds Hash in 1.8.6 compatible way
authorErnest W. Durbin III <ewdurbin@gmail.com>
Fri, 1 Nov 2013 14:12:33 +0000 (1 10:12 -0400)
committerEric Wong <normalperson@yhbt.net>
Fri, 1 Nov 2013 18:43:03 +0000 (1 18:43 +0000)
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 <normalperson@yhbt.net>
lib/unicorn/http_server.rb

index 2decd77..402f133 100644 (file)
@@ -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])