Mercurial > hg > nginx
comparison src/os/unix/ngx_process_cycle.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 | 1a1d55834b5c |
children | ca709bca4b77 |
comparison
equal
deleted
inserted
replaced
6650:1a1d55834b5c | 6651:7d4e33092e2a |
---|---|
783 static void | 783 static void |
784 ngx_worker_process_init(ngx_cycle_t *cycle, ngx_int_t worker) | 784 ngx_worker_process_init(ngx_cycle_t *cycle, ngx_int_t worker) |
785 { | 785 { |
786 sigset_t set; | 786 sigset_t set; |
787 ngx_int_t n; | 787 ngx_int_t n; |
788 ngx_time_t *tp; | |
788 ngx_uint_t i; | 789 ngx_uint_t i; |
789 ngx_cpuset_t *cpu_affinity; | 790 ngx_cpuset_t *cpu_affinity; |
790 struct rlimit rlmt; | 791 struct rlimit rlmt; |
791 ngx_core_conf_t *ccf; | 792 ngx_core_conf_t *ccf; |
792 ngx_listening_t *ls; | 793 ngx_listening_t *ls; |
882 if (sigprocmask(SIG_SETMASK, &set, NULL) == -1) { | 883 if (sigprocmask(SIG_SETMASK, &set, NULL) == -1) { |
883 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | 884 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
884 "sigprocmask() failed"); | 885 "sigprocmask() failed"); |
885 } | 886 } |
886 | 887 |
887 srandom(((unsigned) ngx_pid << 16) ^ ngx_time()); | 888 tp = ngx_timeofday(); |
889 srandom(((unsigned) ngx_pid << 16) ^ tp->sec ^ tp->msec); | |
888 | 890 |
889 /* | 891 /* |
890 * disable deleting previous events for the listening sockets because | 892 * disable deleting previous events for the listening sockets because |
891 * in the worker processes there are no events at all at this point | 893 * in the worker processes there are no events at all at this point |
892 */ | 894 */ |