]> git.meshlink.io Git - meshlink/commitdiff
Properly destroy unclosed channels at meshlink_close() time.
authorGuus Sliepen <guus@meshlink.io>
Sun, 13 Aug 2017 19:53:55 +0000 (21:53 +0200)
committerGuus Sliepen <guus@meshlink.io>
Sun, 13 Aug 2017 19:53:55 +0000 (21:53 +0200)
src/meshlink.c
src/node.c
src/node.h
src/utcp

index fce1f736ea22e0dd6ba1438ab13d24f8d622d710..21144c32ff6f58a67752e578f29bf819f8f637e1 100644 (file)
@@ -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;
 }
index 523c201f47a7dfda533073c1793432da42fe33c2..f55ff370f61269a6c57bdcc532b824a85f057389 100644 (file)
@@ -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);
 
index afcd43eace12e7e59c900d0914ac5337edb69dc1..4e865dfb29510b011637e61f0478faafeb49f90c 100644 (file)
@@ -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;
 
index 0f36bb393e49ecab387b1bfe88741a337d4a8834..1d8aa0d5a55bb871ce56bca355ade80b08a7c1e5 160000 (submodule)
--- a/src/utcp
+++ b/src/utcp
@@ -1 +1 @@
-Subproject commit 0f36bb393e49ecab387b1bfe88741a337d4a8834
+Subproject commit 1d8aa0d5a55bb871ce56bca355ade80b08a7c1e5