From 157c8660a94aea6eddef4dd290ae93d40566b2d8 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 14 Aug 2017 21:22:43 +0200 Subject: [PATCH] Close meta-connections in meshlink_stop(). If we stop MeshLink for an extended time, we don't want to have open sockets lying around that we don't take care of. Terminate all of them. --- src/meshlink.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/meshlink.c b/src/meshlink.c index 35b00482..6e03e63b 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -1044,6 +1044,20 @@ void meshlink_stop(meshlink_handle_t *mesh) { mesh->threadstarted = false; + // Close all metaconnections + if(mesh->connections) { + for(list_node_t *node = mesh->connections->head, *next; node; node = next) { + next = node->next; + connection_t *c = node->data; + c->outgoing = NULL; + terminate_connection(mesh, c, false); + } + } + + if(mesh->outgoings) + list_delete_list(mesh->outgoings); + mesh->outgoings = NULL; + pthread_mutex_unlock(&(mesh->mesh_mutex)); } -- 2.39.5