aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-10-29 00:45:10 +0000
committerBart Polot <bart@net.in.tum.de>2011-10-29 00:45:10 +0000
commit077ab2fba42dedd507ca9e6f6441b00fd46b0090 (patch)
tree6cf86680f285d2fc64ed965c44b65ed92e5a4c99 /src/mesh
parent577cc81d8aec03978a54e220c39c755373ce7467 (diff)
downloadgnunet-077ab2fba42dedd507ca9e6f6441b00fd46b0090.tar.gz
gnunet-077ab2fba42dedd507ca9e6f6441b00fd46b0090.zip
Fixed a bug when adding a path to a peer who is already a relay in the tunnel
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c34
-rw-r--r--src/mesh/mesh_tunnel_tree.c2
2 files changed, 35 insertions, 1 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index a3a9db942..a8b132d7a 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -1286,6 +1286,12 @@ peer_info_connect (struct MeshPeerInfo *peer, struct MeshTunnel *t)
1286 if (NULL != peer->path_head) 1286 if (NULL != peer->path_head)
1287 { 1287 {
1288 p = tree_get_path_to_peer(t->tree, peer->id); 1288 p = tree_get_path_to_peer(t->tree, peer->id);
1289 if (NULL == p)
1290 {
1291 GNUNET_break (0);
1292 return;
1293 }
1294
1289 if (p->length > 1) 1295 if (p->length > 1)
1290 { 1296 {
1291 send_create_path(peer, p, t); 1297 send_create_path(peer, p, t);
@@ -1326,6 +1332,28 @@ peer_info_connect (struct MeshPeerInfo *peer, struct MeshTunnel *t)
1326 1332
1327 1333
1328/** 1334/**
1335 * Task to delay the connection of a peer
1336 *
1337 * @param cls Closure (path info with tunnel and peer to connect).
1338 * Will be free'd on exection.
1339 * @param tc TaskContext
1340 */
1341static void
1342peer_info_connect_task (void *cls,
1343 const struct GNUNET_SCHEDULER_TaskContext *tc)
1344{
1345 struct MeshPathInfo *path_info = cls;
1346
1347 if (GNUNET_SCHEDULER_REASON_SHUTDOWN == tc->reason)
1348 {
1349 GNUNET_free (cls);
1350 }
1351 peer_info_connect (path_info->peer, path_info->t);
1352 GNUNET_free (cls);
1353}
1354
1355
1356/**
1329 * Destroy the peer_info and free any allocated resources linked to it 1357 * Destroy the peer_info and free any allocated resources linked to it
1330 * 1358 *
1331 * @param pi The peer_info to destroy. 1359 * @param pi The peer_info to destroy.
@@ -1718,6 +1746,7 @@ void
1718notify_peer_disconnected (const struct MeshTunnelTreeNode *n) 1746notify_peer_disconnected (const struct MeshTunnelTreeNode *n)
1719{ 1747{
1720 struct MeshPeerInfo *peer; 1748 struct MeshPeerInfo *peer;
1749 struct MeshPathInfo *path_info;
1721 1750
1722 if (NULL != n->t->client && NULL != nc) 1751 if (NULL != n->t->client && NULL != nc)
1723 { 1752 {
@@ -1730,7 +1759,10 @@ notify_peer_disconnected (const struct MeshTunnelTreeNode *n)
1730 &msg.header, GNUNET_NO); 1759 &msg.header, GNUNET_NO);
1731 } 1760 }
1732 peer = peer_info_get_short(n->peer); 1761 peer = peer_info_get_short(n->peer);
1733 peer_info_connect(peer, n->t); 1762 path_info = GNUNET_malloc (sizeof (struct MeshPathInfo));
1763 path_info->peer = peer;
1764 path_info->t = n->t;
1765 GNUNET_SCHEDULER_add_now(&peer_info_connect_task, path_info);
1734} 1766}
1735 1767
1736 1768
diff --git a/src/mesh/mesh_tunnel_tree.c b/src/mesh/mesh_tunnel_tree.c
index 16a9dbd8e..50f6dc5c7 100644
--- a/src/mesh/mesh_tunnel_tree.c
+++ b/src/mesh/mesh_tunnel_tree.c
@@ -516,6 +516,8 @@ tree_get_path_to_peer(struct MeshTunnelTree *t, GNUNET_PEER_Id peer)
516 GNUNET_PEER_Id myid = t->me->peer; 516 GNUNET_PEER_Id myid = t->me->peer;
517 517
518 n = tree_find_peer(t->me, peer); 518 n = tree_find_peer(t->me, peer);
519 if (NULL == n)
520 return NULL;
519 p = path_new(0); 521 p = path_new(0);
520 522
521 /* Building the path (inverted!) */ 523 /* Building the path (inverted!) */