diff src/os/unix/ngx_posix_init.c @ 6651:7d4e33092e2a

Always seed PRNG with PID, seconds, and milliseconds.
author Ruslan Ermilov <ru@nginx.com>
date Thu, 04 Aug 2016 23:43:10 +0300
parents 8f038068f4bc
children 56fc55e32f23
line wrap: on
line diff
--- a/src/os/unix/ngx_posix_init.c	Thu Aug 04 23:42:00 2016 +0300
+++ b/src/os/unix/ngx_posix_init.c	Thu Aug 04 23:43:10 2016 +0300
@@ -33,7 +33,8 @@
 ngx_int_t
 ngx_os_init(ngx_log_t *log)
 {
-    ngx_uint_t  n;
+    ngx_time_t  *tp;
+    ngx_uint_t   n;
 
 #if (NGX_HAVE_OS_SPECIFIC_INIT)
     if (ngx_os_specific_init(log) != NGX_OK) {
@@ -76,7 +77,8 @@
     ngx_inherited_nonblocking = 0;
 #endif
 
-    srandom(ngx_time());
+    tp = ngx_timeofday();
+    srandom(((unsigned) ngx_pid << 16) ^ tp->sec ^ tp->msec);
 
     return NGX_OK;
 }