From 0d237f8c1b3a1ddf57c81a1fda2e66892915aee7 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sat, 1 Nov 2014 15:57:42 +0100 Subject: [PATCH] Clean up UTCP connections when stopping the mesh. --- src/meshlink.h | 3 ++- src/node.c | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/meshlink.h b/src/meshlink.h index 6a83f6c6..5777301a 100644 --- a/src/meshlink.h +++ b/src/meshlink.h @@ -180,6 +180,7 @@ extern bool meshlink_start(meshlink_handle_t *mesh); * close all sockets, and shut down its own thread. * * This function always succeeds. It is allowed to call meshlink_stop() even if MeshLink is already stopped or has never been started. + * Channels that are still open will remain valid, but any communication via channels will stop as well. * * @param mesh A handle which represents an instance of MeshLink. */ @@ -187,7 +188,7 @@ extern void meshlink_stop(meshlink_handle_t *mesh); /// Close the MeshLink handle. /** This function calls meshlink_stop() if necessary, - * and frees the struct meshlink_handle and all associacted memory allocated by MeshLink. + * and frees the struct meshlink_handle and all associacted memory allocated by MeshLink, including all channels. * Afterwards, the handle and any pointers to a struct meshlink_node or struct meshlink_channel are invalid. * * It is allowed to call this function at any time on a valid handle, except inside callback functions. diff --git a/src/node.c b/src/node.c index c6213a17..b838c5be 100644 --- a/src/node.c +++ b/src/node.c @@ -71,14 +71,11 @@ void free_node(node_t *n) { if(n->mtutimeout.cb) abort(); - if(n->hostname) - free(n->hostname); - - if(n->name) - free(n->name); + free(n->hostname); + free(n->name); + free(n->late); - if(n->late) - free(n->late); + utcp_exit(n->utcp); free(n); } -- 2.39.2