tree_node_debug(struct MeshTunnelTreeNode *n, uint16_t level)
{
struct MeshTunnelTreeNode *c;
+ struct GNUNET_PeerIdentity id;;
uint16_t i;
for (i = 0; i < level; i++)
if (n->status == MESH_PEER_RECONNECTING)
fprintf(stderr, "*");
- fprintf(stderr, "%u [%p] ", n->peer, n);
+ GNUNET_PEER_resolve(n->peer, &id);
+ fprintf(stderr, "%s, [%u, %p] ", GNUNET_i2s (&id), n->peer, n);
if (NULL != n->parent)
- fprintf(stderr, "(-> %u)\n", n->parent->peer);
+ {
+ GNUNET_PEER_resolve(n->parent->peer, &id);
+ fprintf(stderr, "(-> %s [%u])\n", GNUNET_i2s(&id), n->parent->peer);
+ }
else
fprintf(stderr, "(root)\n");
for (c = n->children_head; NULL != c; c = c->next)
{
struct MeshTunnelTreeNode *n;
struct MeshTunnelTreeNode *next;
+#if MESH_TREE_DEBUG
+ struct GNUNET_PeerIdentity id;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "tree: Destroying node %u\n",
+ parent->peer);
+ GNUNET_PEER_resolve (parent->peer, &id);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "tree: (%s)\n",
+ GNUNET_i2s (&id));
+#endif
n = parent->children_head;
while (NULL != n)
{
{
tree_mark_peers_disconnected (tree, n, cb);
}
- if (MESH_PEER_READY == parent->status && NULL != cb)
+ if (MESH_PEER_READY == parent->status)
{
- cb (parent);
+ if (NULL != cb)
+ cb (parent);
+ parent->status = MESH_PEER_RECONNECTING;
}
- parent->status = MESH_PEER_RECONNECTING;
/* Remove and free info about first hop */
GNUNET_PEER_resolve(parent->peer, &id);
* NULL when not found
*/
struct MeshTunnelTreeNode *
-tree_del_path (struct MeshTunnelTree *t, GNUNET_PEER_Id peer_id,
- MeshNodeDisconnectCB cb)
+tree_del_path (struct MeshTunnelTree *t,
+ GNUNET_PEER_Id peer_id,
+ MeshNodeDisconnectCB cb)
{
struct MeshTunnelTreeNode *parent;
struct MeshTunnelTreeNode *node;
void
tree_destroy (struct MeshTunnelTree *t)
{
+#if MESH_TREE_DEBUG
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "tree: Destroying tree\n");
+#endif
tree_node_destroy(t->root);
GNUNET_CONTAINER_multihashmap_iterate(t->first_hops, &iterate_free, NULL);
GNUNET_CONTAINER_multihashmap_destroy(t->first_hops);
for (i = 0; i < 10; i++)
{
pi[i] = get_pi(i);
- GNUNET_break (i != GNUNET_PEER_intern(pi[i]));
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Peer %u: %s\n", i,
+ GNUNET_break (i + 1 == GNUNET_PEER_intern(pi[i]));
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Peer %u: %s\n",
+ i + 1,
GNUNET_h2s(&pi[i]->hashPubKey));
}
tree = GNUNET_malloc(sizeof(struct MeshTunnelTree));
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding second path: 1 2 3\n");
path->length--;
- tree_debug(tree);
tree_add_path(tree, path, &cb);
tree_debug(tree);
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
failed++;
}
- if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 1)
+ if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 2)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
failed++;
return 1;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: OK\n");
- path_destroy(path);
+ GNUNET_free (path);
finish();
return 0;