X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet.c;h=9669bc971972488e80ba69391b3841da952f13dc;hb=e62fd508158749a0d55eae06c2e361df5d6da6e0;hp=97ca2dba7dff7f5cbe8402c15a773eb8605595b8;hpb=914d1be411229c28e6e8e4a0df99afa076a8b448;p=tinc diff --git a/src/net.c b/src/net.c index 97ca2dba..9669bc97 100644 --- a/src/net.c +++ b/src/net.c @@ -26,6 +26,7 @@ #include "conf_net.h" #include "conf.h" #include "connection.h" +#include "crypto.h" #include "graph.h" #include "logger.h" #include "meta.h" @@ -159,7 +160,7 @@ void terminate_connection(connection_t *c, bool report) { do_outgoing_connection(outgoing); } -#ifndef HAVE_MINGW +#ifndef HAVE_WINDOWS /* Clean up dead proxy processes */ while(waitpid(-1, NULL, WNOHANG) > 0); @@ -256,7 +257,7 @@ static void timeout_handler(void *data) { } timeout_set(data, &(struct timeval) { - 1, rand() % 100000 + 1, jitter() }); } @@ -268,9 +269,7 @@ static void periodic_handler(void *data) { if(contradicting_del_edge > 100 && contradicting_add_edge > 100) { logger(DEBUG_ALWAYS, LOG_WARNING, "Possible node with same Name as us! Sleeping %d seconds.", sleeptime); - nanosleep(&(struct timespec) { - sleeptime, 0 - }, NULL); + sleep_millis(sleeptime * 1000); sleeptime *= 2; if(sleeptime < 0) { @@ -294,7 +293,7 @@ static void periodic_handler(void *data) { } timeout_set(data, &(struct timeval) { - 5, rand() % 100000 + 5, jitter() }); } @@ -309,7 +308,7 @@ void handle_meta_connection_data(connection_t *c) { } } -#ifndef HAVE_MINGW +#ifndef HAVE_WINDOWS static void sigterm_handler(void *data) { logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum)); event_exit(); @@ -482,13 +481,13 @@ void retry(void) { int main_loop(void) { last_periodic_run_time = now; timeout_add(&pingtimer, timeout_handler, &pingtimer, &(struct timeval) { - pingtimeout, rand() % 100000 + pingtimeout, jitter() }); timeout_add(&periodictimer, periodic_handler, &periodictimer, &(struct timeval) { 0, 0 }); -#ifndef HAVE_MINGW +#ifndef HAVE_WINDOWS signal_t sighup = {0}; signal_t sigterm = {0}; signal_t sigquit = {0}; @@ -507,7 +506,7 @@ int main_loop(void) { return 1; } -#ifndef HAVE_MINGW +#ifndef HAVE_WINDOWS signal_del(&sighup); signal_del(&sigterm); signal_del(&sigquit);