Nodes use events, so event system should be initialised first and destroyed last.
This commit is contained in:
parent
35e4096120
commit
0714ac6c59
5 changed files with 14 additions and 12 deletions
|
@ -96,7 +96,7 @@ event_t *get_expired_event(void)
|
||||||
event = event_tree->head->data;
|
event = event_tree->head->data;
|
||||||
|
|
||||||
if(event->time < now) {
|
if(event->time < now) {
|
||||||
avl_delete(event_tree, event);
|
event_del(event);
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,7 +424,7 @@ int main_loop(void)
|
||||||
|
|
||||||
while((event = get_expired_event())) {
|
while((event = get_expired_event())) {
|
||||||
event->handler(event->data);
|
event->handler(event->data);
|
||||||
free(event);
|
free_event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sigalrm) {
|
if(sigalrm) {
|
||||||
|
|
|
@ -101,7 +101,7 @@ void send_mtu_probe(node_t *n)
|
||||||
send_udppacket(n, &packet);
|
send_udppacket(n, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
n->mtuevent = xmalloc(sizeof(*n->mtuevent));
|
n->mtuevent = new_event();
|
||||||
n->mtuevent->handler = (event_handler_t)send_mtu_probe;
|
n->mtuevent->handler = (event_handler_t)send_mtu_probe;
|
||||||
n->mtuevent->data = n;
|
n->mtuevent->data = n;
|
||||||
n->mtuevent->time = now + 1;
|
n->mtuevent->time = now + 1;
|
||||||
|
|
|
@ -526,11 +526,11 @@ bool setup_network_connections(void)
|
||||||
|
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
|
|
||||||
|
init_events();
|
||||||
init_connections();
|
init_connections();
|
||||||
init_subnets();
|
init_subnets();
|
||||||
init_nodes();
|
init_nodes();
|
||||||
init_edges();
|
init_edges();
|
||||||
init_events();
|
|
||||||
init_requests();
|
init_requests();
|
||||||
|
|
||||||
if(get_config_int(lookup_config(config_tree, "PingInterval"), &pinginterval)) {
|
if(get_config_int(lookup_config(config_tree, "PingInterval"), &pinginterval)) {
|
||||||
|
@ -594,11 +594,11 @@ void close_network_connections(void)
|
||||||
envp[4] = NULL;
|
envp[4] = NULL;
|
||||||
|
|
||||||
exit_requests();
|
exit_requests();
|
||||||
exit_events();
|
|
||||||
exit_edges();
|
exit_edges();
|
||||||
exit_subnets();
|
exit_subnets();
|
||||||
exit_nodes();
|
exit_nodes();
|
||||||
exit_connections();
|
exit_connections();
|
||||||
|
exit_events();
|
||||||
|
|
||||||
execute_script("tinc-down", envp);
|
execute_script("tinc-down", envp);
|
||||||
|
|
||||||
|
|
16
src/node.c
16
src/node.c
|
@ -93,12 +93,6 @@ void free_node(node_t *n)
|
||||||
if(n->queue)
|
if(n->queue)
|
||||||
list_delete_list(n->queue);
|
list_delete_list(n->queue);
|
||||||
|
|
||||||
if(n->name)
|
|
||||||
free(n->name);
|
|
||||||
|
|
||||||
if(n->hostname)
|
|
||||||
free(n->hostname);
|
|
||||||
|
|
||||||
if(n->key)
|
if(n->key)
|
||||||
free(n->key);
|
free(n->key);
|
||||||
|
|
||||||
|
@ -112,9 +106,17 @@ void free_node(node_t *n)
|
||||||
|
|
||||||
EVP_CIPHER_CTX_cleanup(&n->packet_ctx);
|
EVP_CIPHER_CTX_cleanup(&n->packet_ctx);
|
||||||
|
|
||||||
if(n->mtuevent)
|
if(n->mtuevent) {
|
||||||
event_del(n->mtuevent);
|
event_del(n->mtuevent);
|
||||||
|
free_event(n->mtuevent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(n->hostname)
|
||||||
|
free(n->hostname);
|
||||||
|
|
||||||
|
if(n->name)
|
||||||
|
free(n->name);
|
||||||
|
|
||||||
free(n);
|
free(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue