From: Kirill Isakov Date: Sun, 15 Aug 2021 12:43:14 +0000 (+0600) Subject: tincd on Windows: call srand() after main2() X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=commitdiff_plain;h=560ba93b98847b106572da6001c6fa056dd3c612 tincd on Windows: call srand() after main2() On Windows, rand() was returning the same sequence on every service execution, because srand() was initializing its state only for the short-lived process. --- diff --git a/src/tincd.c b/src/tincd.c index dff420a4..560609c1 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -491,8 +491,6 @@ int main(int argc, char **argv) { /* Slllluuuuuuurrrrp! */ - gettimeofday(&now, NULL); - srand(now.tv_sec + now.tv_usec); crypto_init(); if(!read_server_config(&config_tree)) { @@ -546,6 +544,9 @@ int main2(int argc, char **argv) { #endif char *priority = NULL; + gettimeofday(&now, NULL); + srand(now.tv_sec + now.tv_usec); + if(!detach()) { return 1; }