Skip to content

Commit e62a16e

Browse files
committed
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.
1 parent 38ca99c commit e62a16e

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/os/win32/ngx_process_cycle.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ ngx_worker_thread(void *data)
764764
ngx_int_t n;
765765
ngx_cycle_t *cycle;
766766

767+
srand((ngx_pid << 16) ^ (unsigned) ngx_time());
768+
767769
cycle = (ngx_cycle_t *) ngx_cycle;
768770

769771
for (n = 0; cycle->modules[n]; n++) {

0 commit comments

Comments
 (0)