From: Guus Sliepen Date: Sat, 11 Apr 2020 15:43:18 +0000 (+0200) Subject: When resetting timers that use CLOCK_MONOTONIC, use a negative value. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=a10895efa0919ff8e00d1ab732a8690fde2786da;p=meshlink When resetting timers that use CLOCK_MONOTONIC, use a negative value. CLOCK_MONOTONIC might be implemented as the time since the CPU booted, so if MeshLink starts soon after booting, setting timers to "0" might not actually be far enough in the past to trigger a timeout. This has almost no effect in practice, since most timeouts are a minute or less, but it might affect running tests in virtual machines. --- diff --git a/src/devtools.c b/src/devtools.c index fb6ab257..e172b071 100644 --- a/src/devtools.c +++ b/src/devtools.c @@ -353,9 +353,9 @@ void devtool_force_sptps_renewal(meshlink_handle_t *mesh, meshlink_node_t *node) node_t *n = (node_t *)node; connection_t *c = n->connection; - n->last_req_key = 0; + n->last_req_key = -3600; if(c) { - c->last_key_renewal = 0; + c->last_key_renewal = -3600; } } diff --git a/src/discovery.c b/src/discovery.c index db71a5d1..df88b179 100644 --- a/src/discovery.c +++ b/src/discovery.c @@ -263,7 +263,7 @@ static void discovery_resolve_callback(CattaSServiceResolver *resolver, CattaIfI }); } - c->last_ping_time = 0; + c->last_ping_time = -3600; } } else { diff --git a/src/graph.c b/src/graph.c index b0e0b77a..050acbf5 100644 --- a/src/graph.c +++ b/src/graph.c @@ -158,7 +158,7 @@ static void check_reachability(meshlink_handle_t *mesh) { n->status.validkey = false; sptps_stop(&n->sptps); n->status.waitingforkey = false; - n->last_req_key = 0; + n->last_req_key = -3600; n->status.udp_confirmed = false; n->maxmtu = MTU; @@ -196,7 +196,7 @@ static void check_reachability(meshlink_handle_t *mesh) { n->status.validkey = false; sptps_stop(&n->sptps); n->status.waitingforkey = false; - n->last_req_key = 0; + n->last_req_key = -3600; n->status.udp_confirmed = false; n->maxmtu = MTU; diff --git a/src/net.c b/src/net.c index 0aa20439..cfb4d177 100644 --- a/src/net.c +++ b/src/net.c @@ -632,7 +632,7 @@ static void periodic_handler(event_loop_t *loop, void *data) { n->status.validkey = false; sptps_stop(&n->sptps); n->status.waitingforkey = false; - n->last_req_key = 0; + n->last_req_key = -3600; } else { n->last_req_key = mesh->loop.now.tv_sec; } @@ -671,7 +671,7 @@ void retry(meshlink_handle_t *mesh) { } if(!c->status.pinged) { - c->last_ping_time = 0; + c->last_ping_time = -3600; } sockaddr_t sa;