gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r17854 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r17854 - gnunet/src/mesh
Date: Sat, 29 Oct 2011 02:45:10 +0200

Author: bartpolot
Date: 2011-10-29 02:45:10 +0200 (Sat, 29 Oct 2011)
New Revision: 17854

Modified:
   gnunet/src/mesh/gnunet-service-mesh.c
   gnunet/src/mesh/mesh_tunnel_tree.c
Log:
Fixed a bug when adding a path to a peer who is already a relay in the tunnel


Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c       2011-10-28 22:59:45 UTC (rev 
17853)
+++ gnunet/src/mesh/gnunet-service-mesh.c       2011-10-29 00:45:10 UTC (rev 
17854)
@@ -1286,6 +1286,12 @@
   if (NULL != peer->path_head)
   {
     p = tree_get_path_to_peer(t->tree, peer->id);
+    if (NULL == p)
+    {
+      GNUNET_break (0);
+      return;
+    }
+
     if (p->length > 1)
     {
       send_create_path(peer, p, t);
@@ -1326,6 +1332,28 @@
 
 
 /**
+ * Task to delay the connection of a peer
+ *
+ * @param cls Closure (path info with tunnel and peer to connect).
+ *            Will be free'd on exection.
+ * @param tc TaskContext
+ */
+static void
+peer_info_connect_task (void *cls,
+                        const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct MeshPathInfo *path_info = cls;
+
+  if (GNUNET_SCHEDULER_REASON_SHUTDOWN == tc->reason)
+  {
+    GNUNET_free (cls);
+  }
+  peer_info_connect (path_info->peer, path_info->t);
+  GNUNET_free (cls);
+}
+
+
+/**
  * Destroy the peer_info and free any allocated resources linked to it
  * 
  * @param pi The peer_info to destroy.
@@ -1718,6 +1746,7 @@
 notify_peer_disconnected (const struct MeshTunnelTreeNode *n)
 {
   struct MeshPeerInfo *peer;
+  struct MeshPathInfo *path_info;
 
   if (NULL != n->t->client && NULL != nc)
   {
@@ -1730,7 +1759,10 @@
                                                 &msg.header, GNUNET_NO);
   }
   peer = peer_info_get_short(n->peer);
-  peer_info_connect(peer, n->t);
+  path_info = GNUNET_malloc (sizeof (struct MeshPathInfo));
+  path_info->peer = peer;
+  path_info->t = n->t;
+  GNUNET_SCHEDULER_add_now(&peer_info_connect_task, path_info);
 }
 
 

Modified: gnunet/src/mesh/mesh_tunnel_tree.c
===================================================================
--- gnunet/src/mesh/mesh_tunnel_tree.c  2011-10-28 22:59:45 UTC (rev 17853)
+++ gnunet/src/mesh/mesh_tunnel_tree.c  2011-10-29 00:45:10 UTC (rev 17854)
@@ -516,6 +516,8 @@
   GNUNET_PEER_Id myid = t->me->peer;
 
   n = tree_find_peer(t->me, peer);
+  if (NULL == n)
+    return NULL;
   p = path_new(0);
 
   /* Building the path (inverted!) */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]