aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/mesh_tunnel_tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesh/mesh_tunnel_tree.c')
-rw-r--r--src/mesh/mesh_tunnel_tree.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/mesh/mesh_tunnel_tree.c b/src/mesh/mesh_tunnel_tree.c
index 090681517..50a8d57d4 100644
--- a/src/mesh/mesh_tunnel_tree.c
+++ b/src/mesh/mesh_tunnel_tree.c
@@ -263,6 +263,7 @@ tree_new (struct MeshTunnel *t, GNUNET_PEER_Id peer)
263 tree = GNUNET_malloc(sizeof (struct MeshTunnelTree)); 263 tree = GNUNET_malloc(sizeof (struct MeshTunnelTree));
264 tree->first_hops = GNUNET_CONTAINER_multihashmap_create(32); 264 tree->first_hops = GNUNET_CONTAINER_multihashmap_create(32);
265 tree->root = tree_node_new(NULL, peer); 265 tree->root = tree_node_new(NULL, peer);
266 tree->root->status = MESH_PEER_ROOT;
266 tree->t = t; 267 tree->t = t;
267 tree->root->t = t; 268 tree->root->t = t;
268 269
@@ -432,8 +433,7 @@ tree_del_path (struct MeshTunnelTree *t, GNUNET_PEER_Id peer_id,
432 GNUNET_CONTAINER_DLL_remove(parent->children_head, parent->children_tail, n); 433 GNUNET_CONTAINER_DLL_remove(parent->children_head, parent->children_tail, n);
433 n->parent = NULL; 434 n->parent = NULL;
434 435
435 while (t->root != parent && MESH_PEER_RELAY == parent->status && 436 while (MESH_PEER_RELAY == parent->status && NULL == parent->children_head)
436 NULL == parent->children_head)
437 { 437 {
438 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 438 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
439 "tree: Deleting node %u.\n", 439 "tree: Deleting node %u.\n",
@@ -676,7 +676,8 @@ tree_notify_connection_broken (struct MeshTunnelTree *t,
676 676
677 677
678/** 678/**
679 * Deletes a peer from a tunnel, marking its children as disconnected. 679 * Deletes a peer from a tunnel, liberating all unused resources on the path to
680 * it. It shouldn't have children, if it has they will be destroyed as well.
680 * 681 *
681 * @param t Tunnel tree to use. 682 * @param t Tunnel tree to use.
682 * @param peer Short ID of the peer to remove from the tunnel tree. 683 * @param peer Short ID of the peer to remove from the tunnel tree.
@@ -690,24 +691,17 @@ tree_del_peer (struct MeshTunnelTree *t,
690 MeshNodeDisconnectCB cb) 691 MeshNodeDisconnectCB cb)
691{ 692{
692 struct MeshTunnelTreeNode *n; 693 struct MeshTunnelTreeNode *n;
693 struct MeshTunnelTreeNode *c;
694 struct MeshTunnelTreeNode *aux;
695 694
696 n = tree_del_path(t, peer, cb); 695 n = tree_del_path(t, peer, cb);
697 c = n->children_head; 696 if (NULL == n)
698 while (NULL != c) 697 return GNUNET_SYSERR;
698 GNUNET_break_op (NULL == n->children_head);
699 tree_node_destroy(n);
700 if (NULL == t->root->children_head && t->me != t->root)
699 { 701 {
700 aux = c->next; 702 tree_node_destroy (t->root);
701 GNUNET_CONTAINER_DLL_remove(n->children_head, 703 t->root = NULL;
702 n->children_tail,
703 c);
704 GNUNET_CONTAINER_DLL_insert(t->disconnected_head,
705 t->disconnected_tail,
706 c);
707 cb (c);
708 c = aux;
709 } 704 }
710 tree_node_destroy(n);
711 return GNUNET_OK; 705 return GNUNET_OK;
712} 706}
713 707