0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

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).
This commit is contained in:
Ondrej Zajicek (work) 2018-05-03 17:07:39 +02:00
parent 70fab17837
commit eaf63d314d

View File

@ -2144,7 +2144,9 @@ io_init(void)
// XXX init_times(); // XXX init_times();
// XXX update_times(); // XXX update_times();
boot_time = current_time(); 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; static int short_loops = 0;