From: Guus Sliepen Date: Mon, 14 Aug 2017 19:22:43 +0000 (+0200) Subject: Close meta-connections in meshlink_stop(). X-Git-Url: http://git.meshlink.io/?p=meshlink;a=commitdiff_plain;h=157c8660a94aea6eddef4dd290ae93d40566b2d8 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. --- 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)); }