August 08, 2016 04:20AM
details: http://hg.nginx.org/nginx/rev/09c918460cc6
branches:
changeset: 6649:09c918460cc6
user: Ruslan Ermilov <ru@nginx.com>
date: Thu Aug 04 01:15:41 2016 +0300
description:
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.

diffstat:

src/os/win32/ngx_process_cycle.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diffs (12 lines):

diff -r d43ee392e825 -r 09c918460cc6 src/os/win32/ngx_process_cycle.c
--- a/src/os/win32/ngx_process_cycle.c Tue Jul 26 19:34:12 2016 +0300
+++ b/src/os/win32/ngx_process_cycle.c Thu Aug 04 01:15:41 2016 +0300
@@ -764,6 +764,8 @@ ngx_worker_thread(void *data)
ngx_int_t n;
ngx_cycle_t *cycle;

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

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

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Win32: added per-thread random seeding.

ru@nginx.com 703 August 08, 2016 04:20AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 246
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready