X-Git-Url: http://git.meshlink.io/?p=meshlink;a=blobdiff_plain;f=src%2Fmeshlink.c;h=747bd3b5071a406310b4e4e7e8c7d8a463fcd736;hp=fccfecbc404b24e9a9cbfcd67ecce53e221cbeb6;hb=4c57e6902219ecca1872e18e34365d8e54a0f407;hpb=27b37a02bd75e71ed0a95ab201ba15ef4f5cb588 diff --git a/src/meshlink.c b/src/meshlink.c index fccfecbc..747bd3b5 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -995,10 +995,18 @@ static bool ecdsa_keygen(meshlink_handle_t *mesh) { return true; } -static struct timeval idle(event_loop_t *loop, void *data) { +static bool timespec_lt(const struct timespec *a, const struct timespec *b) { + if(a->tv_sec == b->tv_sec) { + return a->tv_nsec < b->tv_nsec; + } else { + return a->tv_sec < b->tv_sec; + } +} + +static struct timespec idle(event_loop_t *loop, void *data) { (void)loop; meshlink_handle_t *mesh = data; - struct timeval t, tmin = {3600, 0}; + struct timespec t, tmin = {3600, 0}; for splay_each(node_t, n, mesh->nodes) { if(!n->utcp) { @@ -1007,7 +1015,7 @@ static struct timeval idle(event_loop_t *loop, void *data) { t = utcp_timeout(n->utcp); - if(timercmp(&t, &tmin, <)) { + if(timespec_lt(&t, &tmin)) { tmin = t; } } @@ -3234,7 +3242,7 @@ static bool blacklist(meshlink_handle_t *mesh, node_t *n) { n->status.udp_confirmed = false; if(n->status.reachable) { - n->last_unreachable = mesh->loop.now.tv_sec; + n->last_unreachable = time(NULL); } /* Graph updates will suppress status updates for blacklisted nodes, so we need to @@ -3308,7 +3316,7 @@ static bool whitelist(meshlink_handle_t *mesh, node_t *n) { n->status.blacklisted = false; if(n->status.reachable) { - n->last_reachable = mesh->loop.now.tv_sec; + n->last_reachable = time(NULL); update_node_status(mesh, n); }