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.
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));
}