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));
}
}
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) {
abort();
node_t *n = channel->node;
meshlink_handle_t *mesh = n->mesh;
- if(channel->receive_cb)
+ if(n->status.destroyed)
+ meshlink_channel_close(mesh, channel);
+ else if(channel->receive_cb)
channel->receive_cb(mesh, channel, data, len);
return len;
}