about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/unicorn/http_server.rb9
1 files 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