From: Guus Sliepen Date: Sat, 1 Nov 2014 14:57:42 +0000 (+0100) Subject: Clean up UTCP connections when stopping the mesh. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=0d237f8c1b3a1ddf57c81a1fda2e66892915aee7;p=meshlink Clean up UTCP connections when stopping the mesh. --- 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); }