diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2018-05-03 17:07:39 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2018-05-03 17:07:39 +0200 |
commit | eaf63d314d50cba5b2cfa8f18de64a91d3131b94 (patch) | |
tree | 135a96eec944ee967296b7fb3472a1b1673b7043 /sysdep/unix | |
parent | 70fab17837dbb4c5848681e4c6b9b90891891130 (diff) |
Better initialization of random generator
Use full time precision to initialize random generator. The old
code was prone to initialize it to the same values in specific
circumstances (boot without RTC, multiple VMs starting at once).
Diffstat (limited to 'sysdep/unix')
-rw-r--r-- | sysdep/unix/io.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index 012deaf0..11a0d6f1 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -2144,7 +2144,9 @@ io_init(void) // XXX init_times(); // XXX update_times(); boot_time = current_time(); - srandom((uint) (current_real_time() TO_S)); + + u64 now = (u64) current_real_time(); + srandom((uint) (now ^ (now >> 32))); } static int short_loops = 0; |