]> git.meshlink.io Git - meshlink/commitdiff
When resetting timers that use CLOCK_MONOTONIC, use a negative value.
authorGuus Sliepen <guus@meshlink.io>
Sat, 11 Apr 2020 15:43:18 +0000 (17:43 +0200)
committerGuus Sliepen <guus@meshlink.io>
Sat, 11 Apr 2020 15:45:03 +0000 (17:45 +0200)
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.

src/devtools.c
src/discovery.c
src/graph.c
src/net.c

index fb6ab257a0f3eae901ff869c53a774aeb48c413d..e172b0717950cd43fe526b8796e58fb7e2949ff0 100644 (file)
@@ -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;
        }
 }
index db71a5d15a47034d100745eda2a395c8b8310721..df88b17919178a5075a769cf5f191256911c3810 100644 (file)
@@ -263,7 +263,7 @@ static void discovery_resolve_callback(CattaSServiceResolver *resolver, CattaIfI
                                                        });
                                                }
 
-                                               c->last_ping_time = 0;
+                                               c->last_ping_time = -3600;
                                        }
 
                                } else {
index b0e0b77a198a408cd2d88aecb2c4debde09022d3..050acbf5f4d45f0c375c5a077b139ccf9c1290b7 100644 (file)
@@ -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;
index 0aa20439a87de39d518cb130d7c7d4852be27d9f..cfb4d1775412db4b040b4824b39295a0fdbb2e72 100644 (file)
--- 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;