X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnode.c;h=164fdb159e701b8da13785b4c0ceb90e2e67792b;hb=ea294dac41365a08a77b64c62c0ba630292d7a07;hp=b838c5bee4eba1a5c51afccb560878f7c21dc435;hpb=0d237f8c1b3a1ddf57c81a1fda2e66892915aee7;p=meshlink diff --git a/src/node.c b/src/node.c index b838c5be..164fdb15 100644 --- a/src/node.c +++ b/src/node.c @@ -48,9 +48,8 @@ void exit_nodes(meshlink_handle_t *mesh) { } node_t *new_node(void) { - node_t *n = xzalloc(sizeof *n); + node_t *n = xzalloc(sizeof(*n)); - if(replaywin) n->late = xzalloc(replaywin); n->edge_tree = new_edge_tree(); n->mtu = MTU; n->maxmtu = MTU; @@ -60,6 +59,8 @@ node_t *new_node(void) { } void free_node(node_t *n) { + n->status.destroyed = true; + if(n->edge_tree) free_edge_tree(n->edge_tree); @@ -71,9 +72,7 @@ void free_node(node_t *n) { if(n->mtutimeout.cb) abort(); - free(n->hostname); free(n->name); - free(n->late); utcp_exit(n->utcp); @@ -124,9 +123,15 @@ void update_node_udp(meshlink_handle_t *mesh, node_t *n, const sockaddr_t *sa) { break; } } + hash_insert(mesh->node_udp_cache, sa, n); - free(n->hostname); - n->hostname = sockaddr2hostname(&n->address); - logger(mesh, MESHLINK_DEBUG, "UDP address of %s set to %s", n->name, n->hostname); + + meshlink_hint_address(mesh, (meshlink_node_t *)n, &sa->sa); + + if(mesh->log_level >= MESHLINK_DEBUG) { + char *hostname = sockaddr2hostname(&n->address); + logger(mesh, MESHLINK_DEBUG, "UDP address of %s set to %s", n->name, hostname); + free(hostname); + } } }