[nginx] Added per-process random seeding (ticket #456).
Maxim Dounin
mdounin at mdounin.ru
Fri Jan 3 23:49:07 UTC 2014
details: http://hg.nginx.org/nginx/rev/b91bcba29351
branches:
changeset: 5499:b91bcba29351
user: Maxim Dounin <mdounin at mdounin.ru>
date: Sat Jan 04 03:32:06 2014 +0400
description:
Added per-process random seeding (ticket #456).
diffstat:
src/os/unix/ngx_process_cycle.c | 2 ++
src/os/win32/ngx_win32_init.c | 2 +-
2 files changed, 3 insertions(+), 1 deletions(-)
diffs (24 lines):
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -959,6 +959,8 @@ ngx_worker_process_init(ngx_cycle_t *cyc
"sigprocmask() failed");
}
+ srandom((ngx_pid << 16) ^ ngx_time());
+
/*
* disable deleting previous events for the listening sockets because
* in the worker processes there are no events at all at this point
diff --git a/src/os/win32/ngx_win32_init.c b/src/os/win32/ngx_win32_init.c
--- a/src/os/win32/ngx_win32_init.c
+++ b/src/os/win32/ngx_win32_init.c
@@ -228,7 +228,7 @@ ngx_os_init(ngx_log_t *log)
ngx_sprintf((u_char *) ngx_unique, "%P%Z", ngx_pid);
}
- srand((unsigned) ngx_time());
+ srand((ngx_pid << 16) ^ (unsigned) ngx_time());
return NGX_OK;
}
More information about the nginx-devel
mailing list