]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.c
Close meta-connections in meshlink_stop().
[meshlink] / src / meshlink.c
index 21144c32ff6f58a67752e578f29bf819f8f637e1..6e03e63bbe7e1b3848ccb8678c2a8b9fd4207d22 100644 (file)
@@ -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));
 }
 
@@ -2146,8 +2160,9 @@ meshlink_edge_t **meshlink_get_all_edges_state(meshlink_handle_t *mesh, meshlink
 }
 
 static bool channel_pre_accept(struct utcp *utcp, uint16_t port) {
-       //TODO: implement
-       return true;
+       node_t *n = utcp->priv;
+       meshlink_handle_t *mesh = n->mesh;
+       return mesh->channel_accept_cb;
 }
 
 static ssize_t channel_recv(struct utcp_connection *connection, const void *data, size_t len) {