Dont add whole path to peer, just the relevant part
authorBart Polot <bart@net.in.tum.de>
Mon, 31 Oct 2011 16:27:32 +0000 (16:27 +0000)
committerBart Polot <bart@net.in.tum.de>
Mon, 31 Oct 2011 16:27:32 +0000 (16:27 +0000)
src/mesh/gnunet-service-mesh.c

index ca60433dea9b56eecd19cdbabed58ea4e2688ae7..9b76e6b1e6e3cde432be72e2e123e2b7092c7c3f 100644 (file)
@@ -1509,18 +1509,34 @@ path_add_to_peer (struct MeshPeerInfo *peer_info, struct MeshPeerPath *path)
     path_destroy (path);
     return;
   }
+  for (l = 1; l < path->length; l++)
+  {
+    if (path->peers[l] == myid)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "MESH: shortening path by %u\n",
+                  l);
+      for (l2 = 0; l2 < path->length - l - 1 ; l2++)
+      {
+        path->peers[l2] = path->peers[l + l2];
+      }
+      path->length -= l;
+      l = 0;
+      path->peers = GNUNET_realloc (path->peers,
+                                    path->length * sizeof (GNUNET_PEER_Id));
+    }
+  }
 #if MESH_DEBUG
   { 
     struct GNUNET_PeerIdentity id;
-    
+
     GNUNET_PEER_resolve (peer_info->id, &id);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "MESH: adding path [%u] to peer %s\n",
-               path->length,
-               GNUNET_i2s (&id));
+                "MESH: adding path [%u] to peer %s\n",
+                path->length,
+                GNUNET_i2s (&id));
   }
 #endif
-
   l = path_get_length (path);
   if (0 == l)
   {