From b32416211ef30e958ec38c8c99833161cd476dd4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 18 Apr 2011 22:21:58 +0000 Subject: reinitialize PRNG for latest Ruby 1.8.7 releases The current versions of Ruby 1.8 do not reseed the PRNG after forking, so we'll work around that by calling Kernel#srand. ref: http://redmine.ruby-lang.org/issues/show/4338 --- lib/unicorn/http_server.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb index 07d0b4f..2706568 100644 --- a/lib/unicorn/http_server.rb +++ b/lib/unicorn/http_server.rb @@ -484,14 +484,19 @@ class Unicorn::HttpServer next_sleep end + def after_fork_internal + @ready_pipe.close if @ready_pipe + @ready_pipe = nil + srand # http://redmine.ruby-lang.org/issues/4338 + end + def spawn_missing_workers (0...worker_processes).each do |worker_nr| WORKERS.values.include?(worker_nr) and next worker = Worker.new(worker_nr, Unicorn::TmpIO.new) before_fork.call(self, worker) WORKERS[fork { - ready_pipe.close if ready_pipe - self.ready_pipe = nil + after_fork_internal worker_loop(worker) }] = worker end -- cgit v1.2.3-24-ge0c7