X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet.c;h=8cb7ed739f6a2e793f7643b23b8c4c779f8d3c53;hb=1be0c284c7c8d34c2dd6c2160ce49aeae468e867;hp=577b11fde99a503be495586399c2d2bbe9e199fe;hpb=9d0e86683cdb7d53263569ad2e49dd87bd217939;p=tinc diff --git a/src/net.c b/src/net.c index 577b11fd..8cb7ed73 100644 --- a/src/net.c +++ b/src/net.c @@ -94,29 +94,31 @@ void purge(void) { void terminate_connection(connection_t *c, bool report) { logger(DEBUG_CONNECTIONS, LOG_NOTICE, "Closing connection with %s (%s)", c->name, c->hostname); - if(c->node && c->node->connection == c) - c->node->connection = NULL; + if(c->node) { + if(c->node->connection == c) + c->node->connection = NULL; - if(c->edge) { - if(report && !tunnelserver) - send_del_edge(everyone, c->edge); + if(c->edge) { + if(report && !tunnelserver) + send_del_edge(everyone, c->edge); - edge_del(c->edge); - c->edge = NULL; + edge_del(c->edge); + c->edge = NULL; - /* Run MST and SSSP algorithms */ + /* Run MST and SSSP algorithms */ - graph(); + graph(); - /* If the node is not reachable anymore but we remember it had an edge to us, clean it up */ + /* If the node is not reachable anymore but we remember it had an edge to us, clean it up */ - if(report && !c->node->status.reachable) { - edge_t *e; - e = lookup_edge(c->node, myself); - if(e) { - if(!tunnelserver) - send_del_edge(everyone, e); - edge_del(e); + if(report && !c->node->status.reachable) { + edge_t *e; + e = lookup_edge(c->node, myself); + if(e) { + if(!tunnelserver) + send_del_edge(everyone, e); + edge_del(e); + } } } } @@ -207,7 +209,7 @@ static void timeout_handler(void *data) { // timeout during ping if(c->status.pinged) { - logger(DEBUG_CONNECTIONS, LOG_INFO, "%s (%s) didn't respond to PING in %ld seconds", c->name, c->hostname, (long)now.tv_sec - c->last_ping_time); + logger(DEBUG_CONNECTIONS, LOG_INFO, "%s (%s) didn't respond to PING in %ld seconds", c->name, c->hostname, (long)(now.tv_sec - c->last_ping_time)); terminate_connection(c, c->edge); continue; }