comparison 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
comparison
equal deleted inserted replaced
6650:1a1d55834b5c 6651:7d4e33092e2a
31 31
32 32
33 ngx_int_t 33 ngx_int_t
34 ngx_os_init(ngx_log_t *log) 34 ngx_os_init(ngx_log_t *log)
35 { 35 {
36 ngx_uint_t n; 36 ngx_time_t *tp;
37 ngx_uint_t n;
37 38
38 #if (NGX_HAVE_OS_SPECIFIC_INIT) 39 #if (NGX_HAVE_OS_SPECIFIC_INIT)
39 if (ngx_os_specific_init(log) != NGX_OK) { 40 if (ngx_os_specific_init(log) != NGX_OK) {
40 return NGX_ERROR; 41 return NGX_ERROR;
41 } 42 }
74 ngx_inherited_nonblocking = 1; 75 ngx_inherited_nonblocking = 1;
75 #else 76 #else
76 ngx_inherited_nonblocking = 0; 77 ngx_inherited_nonblocking = 0;
77 #endif 78 #endif
78 79
79 srandom(ngx_time()); 80 tp = ngx_timeofday();
81 srandom(((unsigned) ngx_pid << 16) ^ tp->sec ^ tp->msec);
80 82
81 return NGX_OK; 83 return NGX_OK;
82 } 84 }
83 85
84 86