about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-04-26 16:01:31 -0700
committerEric Wong <normalperson@yhbt.net>2011-04-26 16:01:31 -0700
commit34f7dbd1b7e087bc8c86029496fd8daa7dc58441 (patch)
treeda174bb12cd85a2adec78d20851f73894fe918a1
parent2aabf90ca53b31edef6c2b63006c33374840c816 (diff)
downloadunicorn-34f7dbd1b7e087bc8c86029496fd8daa7dc58441.tar.gz
Using the return value of Kernel#srand actually made the
problem worse.  Using the value of Kernel#rand is required
to actually get a random value to seed the OpenSSL PRNG.

Thanks to ghazel for the bug report!
-rw-r--r--lib/unicorn/http_server.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb
index d70de45..3077b95 100644
--- a/lib/unicorn/http_server.rb
+++ b/lib/unicorn/http_server.rb
@@ -492,11 +492,11 @@ class Unicorn::HttpServer
   def after_fork_internal
     @ready_pipe.close if @ready_pipe
     self.ready_pipe = nil # XXX Rainbows! compat, change for Unicorn 4.x
-    tmp = srand # http://redmine.ruby-lang.org/issues/4338
+    srand # http://redmine.ruby-lang.org/issues/4338
 
     # The OpenSSL PRNG is seeded with only the pid, and apps with frequently
     # dying workers can recycle pids
-    OpenSSL::Random.seed(tmp.to_s) if defined?(OpenSSL::Random)
+    OpenSSL::Random.seed(rand.to_s) if defined?(OpenSSL::Random)
   end
 
   def spawn_missing_workers