mirror of
https://github.com/nginx/nginx.git
synced 2025-02-25 18:55:26 -06:00
Always seed PRNG with PID, seconds, and milliseconds.
This commit is contained in:
parent
31389e4921
commit
42f6e1f78e
@ -33,7 +33,8 @@ ngx_os_io_t ngx_os_io = {
|
|||||||
ngx_int_t
|
ngx_int_t
|
||||||
ngx_os_init(ngx_log_t *log)
|
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_HAVE_OS_SPECIFIC_INIT)
|
||||||
if (ngx_os_specific_init(log) != NGX_OK) {
|
if (ngx_os_specific_init(log) != NGX_OK) {
|
||||||
@ -76,7 +77,8 @@ ngx_os_init(ngx_log_t *log)
|
|||||||
ngx_inherited_nonblocking = 0;
|
ngx_inherited_nonblocking = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
srandom(ngx_time());
|
tp = ngx_timeofday();
|
||||||
|
srandom(((unsigned) ngx_pid << 16) ^ tp->sec ^ tp->msec);
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
@ -785,6 +785,7 @@ ngx_worker_process_init(ngx_cycle_t *cycle, ngx_int_t worker)
|
|||||||
{
|
{
|
||||||
sigset_t set;
|
sigset_t set;
|
||||||
ngx_int_t n;
|
ngx_int_t n;
|
||||||
|
ngx_time_t *tp;
|
||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
ngx_cpuset_t *cpu_affinity;
|
ngx_cpuset_t *cpu_affinity;
|
||||||
struct rlimit rlmt;
|
struct rlimit rlmt;
|
||||||
@ -884,7 +885,8 @@ ngx_worker_process_init(ngx_cycle_t *cycle, ngx_int_t worker)
|
|||||||
"sigprocmask() failed");
|
"sigprocmask() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
srandom(((unsigned) ngx_pid << 16) ^ ngx_time());
|
tp = ngx_timeofday();
|
||||||
|
srandom(((unsigned) ngx_pid << 16) ^ tp->sec ^ tp->msec);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* disable deleting previous events for the listening sockets because
|
* disable deleting previous events for the listening sockets because
|
||||||
|
@ -762,9 +762,11 @@ static ngx_thread_value_t __stdcall
|
|||||||
ngx_worker_thread(void *data)
|
ngx_worker_thread(void *data)
|
||||||
{
|
{
|
||||||
ngx_int_t n;
|
ngx_int_t n;
|
||||||
|
ngx_time_t *tp;
|
||||||
ngx_cycle_t *cycle;
|
ngx_cycle_t *cycle;
|
||||||
|
|
||||||
srand((ngx_pid << 16) ^ (unsigned) ngx_time());
|
tp = ngx_timeofday();
|
||||||
|
srand((ngx_pid << 16) ^ (unsigned) tp->sec ^ tp->msec);
|
||||||
|
|
||||||
cycle = (ngx_cycle_t *) ngx_cycle;
|
cycle = (ngx_cycle_t *) ngx_cycle;
|
||||||
|
|
||||||
|
@ -59,12 +59,13 @@ static GUID dx_guid = WSAID_DISCONNECTEX;
|
|||||||
ngx_int_t
|
ngx_int_t
|
||||||
ngx_os_init(ngx_log_t *log)
|
ngx_os_init(ngx_log_t *log)
|
||||||
{
|
{
|
||||||
DWORD bytes;
|
DWORD bytes;
|
||||||
SOCKET s;
|
SOCKET s;
|
||||||
WSADATA wsd;
|
WSADATA wsd;
|
||||||
ngx_err_t err;
|
ngx_err_t err;
|
||||||
ngx_uint_t n;
|
ngx_time_t *tp;
|
||||||
SYSTEM_INFO si;
|
ngx_uint_t n;
|
||||||
|
SYSTEM_INFO si;
|
||||||
|
|
||||||
/* get Windows version */
|
/* get Windows version */
|
||||||
|
|
||||||
@ -237,7 +238,8 @@ ngx_os_init(ngx_log_t *log)
|
|||||||
ngx_sprintf((u_char *) ngx_unique, "%P%Z", ngx_pid);
|
ngx_sprintf((u_char *) ngx_unique, "%P%Z", ngx_pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
srand((ngx_pid << 16) ^ (unsigned) ngx_time());
|
tp = ngx_timeofday();
|
||||||
|
srand((ngx_pid << 16) ^ (unsigned) tp->sec ^ tp->msec);
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user