Initialize random with better seed

This commit is contained in:
sfan5 2024-01-16 18:31:25 +01:00
parent 6caa06eaed
commit e985b7a0bf

@ -691,8 +691,12 @@ static bool init_common(const Settings &cmd_args, int argc, char *argv[])
init_log_streams(cmd_args); init_log_streams(cmd_args);
// Initialize random seed // Initialize random seed
srand(time(0)); {
mysrand(time(0)); u32 seed = static_cast<u32>(time(nullptr)) << 16;
seed |= porting::getTimeUs() & 0xffff;
srand(seed);
mysrand(seed);
}
// Initialize HTTP fetcher // Initialize HTTP fetcher
httpfetch_init(g_settings->getS32("curl_parallel_limit")); httpfetch_init(g_settings->getS32("curl_parallel_limit"));