/*
net.c -- most of the network code
Copyright (C) 1998-2005 Ivo Timmermans,
- 2000-2011 Guus Sliepen <guus@tinc-vpn.org>
+ 2000-2012 Guus Sliepen <guus@tinc-vpn.org>
2006 Scott Lamb <slamb@slamb.org>
2011 Loïc Grenié <loic.grenie@gmail.com>
c->status.active = false;
- if(c->node)
+ if(c->node && c->node->connection == c)
c->node->connection = NULL;
if(c->edge) {
send_del_edge(everyone, c->edge);
edge_del(c->edge);
+ c->edge = NULL;
/* Run MST and SSSP algorithms */
}
}
- /* Check if this was our outgoing connection */
+ free_connection_partially(c);
- if(c->outgoing)
- retry_outgoing(c->outgoing);
+ /* Check if this was our outgoing connection */
- connection_del(c);
+ if(c->outgoing) {
+ do_outgoing_connection(c);
+ } else {
+ connection_del(c);
+ }
}
/*
if(c->status.active) {
if(c->status.pinged) {
logger(DEBUG_CONNECTIONS, LOG_INFO, "%s (%s) didn't respond to PING in %ld seconds",
- c->name, c->hostname, now - c->last_ping_time);
+ c->name, c->hostname, (long)now - c->last_ping_time);
terminate_connection(c, true);
continue;
} else if(c->last_ping_time + pinginterval <= now) {
void retry(void) {
connection_t *c;
- splay_node_t *node;
+ splay_node_t *node, *next;
- for(node = connection_tree->head; node; node = node->next) {
+ for(node = connection_tree->head; node; node = next) {
+ next = node->next;
c = node->data;
if(c->outgoing && !c->node) {