From: Guus Sliepen Date: Sun, 13 Aug 2017 19:53:55 +0000 (+0200) Subject: Properly destroy unclosed channels at meshlink_close() time. X-Git-Url: http://git.meshlink.io/?p=meshlink;a=commitdiff_plain;h=b88b573eb91ee7dca96ad0a5269bc455e8c97c14 Properly destroy unclosed channels at meshlink_close() time. --- diff --git a/src/meshlink.c b/src/meshlink.c index fce1f736..21144c32 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -2156,7 +2156,9 @@ static ssize_t channel_recv(struct utcp_connection *connection, const void *data abort(); node_t *n = channel->node; meshlink_handle_t *mesh = n->mesh; - if(channel->receive_cb) + if(n->status.destroyed) + meshlink_channel_close(mesh, channel); + else if(channel->receive_cb) channel->receive_cb(mesh, channel, data, len); return len; } diff --git a/src/node.c b/src/node.c index 523c201f..f55ff370 100644 --- a/src/node.c +++ b/src/node.c @@ -59,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); diff --git a/src/node.h b/src/node.h index afcd43ea..4e865dfb 100644 --- a/src/node.h +++ b/src/node.h @@ -35,7 +35,8 @@ typedef struct node_status_t { unsigned int unused_sptps: 1; /* 1 if this node supports SPTPS */ unsigned int udp_confirmed: 1; /* 1 if the address is one that we received UDP traffic on */ unsigned int broadcast: 1; /* 1 if the next UDP packet should be broadcast to the local network */ - unsigned int blacklisted: 1; /* 1 if the node is blacklist so we never want to speak with him anymore*/ + unsigned int blacklisted: 1; /* 1 if the node is blacklist so we never want to speak with him anymore */ + unsigned int destroyed: 1; /* 1 if the node is being destroyed, deallocate channels when any callback is triggered */ unsigned int unused: 22; } node_status_t; diff --git a/src/utcp b/src/utcp index 0f36bb39..1d8aa0d5 160000 --- a/src/utcp +++ b/src/utcp @@ -1 +1 @@ -Subproject commit 0f36bb393e49ecab387b1bfe88741a337d4a8834 +Subproject commit 1d8aa0d5a55bb871ce56bca355ade80b08a7c1e5