comparison src/os/win32/ngx_process_cycle.c @ 6649:09c918460cc6

Win32: added per-thread random seeding. The change in b91bcba29351 was not enough to fix random() seeding. On Windows, the srand() seeds the PRNG only in the current thread, and worse, is not inherited from the calling thread. Due to this, worker threads were not properly seeded. Reported by Marc Bevand.
author Ruslan Ermilov <ru@nginx.com>
date Thu, 04 Aug 2016 01:15:41 +0300
parents 7640d6c213e1
children 7d4e33092e2a
comparison
equal deleted inserted replaced
6648:d43ee392e825 6649:09c918460cc6
762 ngx_worker_thread(void *data) 762 ngx_worker_thread(void *data)
763 { 763 {
764 ngx_int_t n; 764 ngx_int_t n;
765 ngx_cycle_t *cycle; 765 ngx_cycle_t *cycle;
766 766
767 srand((ngx_pid << 16) ^ (unsigned) ngx_time());
768
767 cycle = (ngx_cycle_t *) ngx_cycle; 769 cycle = (ngx_cycle_t *) ngx_cycle;
768 770
769 for (n = 0; cycle->modules[n]; n++) { 771 for (n = 0; cycle->modules[n]; n++) {
770 if (cycle->modules[n]->init_process) { 772 if (cycle->modules[n]->init_process) {
771 if (cycle->modules[n]->init_process(cycle) == NGX_ERROR) { 773 if (cycle->modules[n]->init_process(cycle) == NGX_ERROR) {