- don't loop on the same invalid path
authorBart Polot <bart@net.in.tum.de>
Mon, 16 Dec 2013 11:55:37 +0000 (11:55 +0000)
committerBart Polot <bart@net.in.tum.de>
Mon, 16 Dec 2013 11:55:37 +0000 (11:55 +0000)
src/mesh/gnunet-service-mesh_connection.c
src/mesh/gnunet-service-mesh_peer.c
src/mesh/gnunet-service-mesh_peer.h
src/mesh/gnunet-service-mesh_tunnel.c
src/mesh/gnunet-service-mesh_tunnel.h

index 85a10bcfe32d9b2e3bc99a3f4535495289f3b40d..8ae297f6359067377de63fb5a66fd85a4b983e29 100644 (file)
@@ -179,7 +179,8 @@ struct MeshConnection
   enum MeshConnectionState state;
 
   /**
-   * Path being used for the tunnel.
+   * Path being used for the tunnel. At the origin of the connection
+   * it's a pointer to the destination's path pool, otherwise just a copy.
    */
   struct MeshPeerPath *path;
 
@@ -1149,7 +1150,7 @@ register_neighbors (struct MeshConnection *c)
       || GNUNET_NO == GMP_is_neighbor (prev_peer))
   {
     if (GMC_is_origin (c, GNUNET_YES))
-      GNUNET_STATISTICS_update (stats, "# local bad paths", 1, GNUNET_NO);
+    GNUNET_STATISTICS_update (stats, "# local bad paths", 1, GNUNET_NO);
     GNUNET_STATISTICS_update (stats, "# bad paths", 1, GNUNET_NO);
 
     LOG (GNUNET_ERROR_TYPE_DEBUG, "  register neighbors failed\n");
@@ -2220,6 +2221,11 @@ GMC_new (const struct GNUNET_HashCode *cid,
 
   if (GNUNET_OK != register_neighbors (c))
   {
+    if (0 == own_pos)
+    {
+      GMT_remove_path (c->t, p);
+      path_destroy (p);
+    }
     GMC_destroy (c);
     return NULL;
   }
index 30c64377f5e584daaedf08ac9488b4471c911ebd..2adc9483b35e8a44f96db0aeea9da66917700daa 100644 (file)
@@ -1594,6 +1594,32 @@ GMP_add_path_to_all (const struct MeshPeerPath *p, int confirmed)
 }
 
 
+/**
+ * Remove any path to the peer that has the extact same peers as the one given.
+ *
+ * @param peer Peer to remove the path from.
+ * @param path Path to remove.
+ */
+void
+GMP_remove_path (struct MeshPeer *peer, struct MeshPeerPath *path)
+{
+  struct MeshPeerPath *iter;
+  struct MeshPeerPath *next;
+
+  GNUNET_assert (myid == path->peers[path->length - 1]);
+
+  for (iter = peer->path_head; NULL != iter; iter = next)
+  {
+    next = iter->next;
+    if (0 == memcmp (path->peers, iter->peers,
+                     sizeof (GNUNET_PEER_Id) * path->length))
+    {
+      path_destroy (iter);
+    }
+  }
+}
+
+
 /**
  * Remove a connection from a neighboring peer.
  *
index 58386c0aa0f71502a6aecab286883dde60f9be13..2377c205206815764082576ef443fef4a440df9d 100644 (file)
@@ -250,6 +250,15 @@ GMP_add_path_to_origin (struct MeshPeer *peer,
 void
 GMP_add_path_to_all (const struct MeshPeerPath *p, int confirmed);
 
+/**
+ * Remove any path to the peer that has the extact same peers as the one given.
+ *
+ * @param peer Peer to remove the path from.
+ * @param path Path to remove.
+ */
+void
+GMP_remove_path (struct MeshPeer *peer, struct MeshPeerPath *path);
+
 /**
  * Remove a connection from a neighboring peer.
  *
index 181395b09bc70557fb22ce42712a3699970a5133..82fcde649519a2dde27cfa48f65adb3d950ba59e 100644 (file)
@@ -1755,6 +1755,19 @@ GMT_add_connection (struct MeshTunnel3 *t, struct MeshConnection *c)
 }
 
 
+/**
+ * Mark a path as no longer valid for this tunnel: has been tried and failed.
+ *
+ * @param t Tunnel to update.
+ * @param path Invalid path.
+ */
+void
+GMT_remove_path (struct MeshTunnel3 *t, struct MeshPeerPath *path)
+{
+  GMP_remove_path (t->peer, path);
+}
+
+
 /**
  * Remove a connection from a tunnel.
  *
index 26064c642d8d20c5c1e014c4d892ba67d8a60088..af36ff4e5d4bdb574d97c569e5de2cab95317d1b 100644 (file)
@@ -213,6 +213,15 @@ GMT_change_estate (struct MeshTunnel3* t, enum MeshTunnel3EState state);
 void
 GMT_add_connection (struct MeshTunnel3 *t, struct MeshConnection *c);
 
+/**
+ * Mark a path as no longer valid for this tunnel: has been tried and failed.
+ *
+ * @param t Tunnel to update.
+ * @param path Invalid path.
+ */
+void
+GMT_remove_path (struct MeshTunnel3 *t, struct MeshPeerPath *path);
+
 /**
  * Remove a connection from a tunnel.
  *