gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r31474 - gnunet/src/mesh
Date: Tue, 17 Dec 2013 13:34:35 +0100

Author: bartpolot
Date: 2013-12-17 13:34:35 +0100 (Tue, 17 Dec 2013)
New Revision: 31474

Modified:
   gnunet/src/mesh/gnunet-service-mesh_connection.c
   gnunet/src/mesh/gnunet-service-mesh_peer.c
   gnunet/src/mesh/gnunet-service-mesh_tunnel.c
   gnunet/src/mesh/mesh_path.c
   gnunet/src/mesh/mesh_path.h
Log:
- dont destroy a path right away, broken paths can cause long loops with 
outdated DHT data


Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-12-17 10:05:04 UTC 
(rev 31473)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-12-17 12:34:35 UTC 
(rev 31474)
@@ -1152,6 +1152,11 @@
   next_peer = get_next_hop (c);
   prev_peer = get_prev_hop (c);
 
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "putting connection %s to next peer %s\n",
+       GMC_2s (c), GMP_2s (next_peer));
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "putting connection %s to prev peer %s\n",
+       GMC_2s (c), GMP_2s (prev_peer));
+
   if (GNUNET_NO == GMP_is_neighbor (next_peer)
       || GNUNET_NO == GMP_is_neighbor (prev_peer))
   {
@@ -2301,7 +2306,7 @@
   {
     if (0 == own_pos)
     {
-      GMT_remove_path (c->t, p);
+      path_invalidate (c->path);
       c->t = NULL;
       c->path = NULL;
     }

Modified: gnunet/src/mesh/gnunet-service-mesh_peer.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.c  2013-12-17 10:05:04 UTC (rev 
31473)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.c  2013-12-17 12:34:35 UTC (rev 
31474)
@@ -669,6 +669,9 @@
     if (GNUNET_YES == GMT_is_path_used (peer->tunnel, p))
       continue; /* If path is already in use, skip it. */
 
+    if (GNUNET_NO == path_is_valid (p))
+      continue; /* Don't use invalid paths. */
+
     if ((cost = GMT_get_path_cost (peer->tunnel, p)) < best_cost)
     {
       best_cost = cost;

Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.c        2013-12-17 10:05:04 UTC 
(rev 31473)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.c        2013-12-17 12:34:35 UTC 
(rev 31474)
@@ -1572,6 +1572,7 @@
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "end-to-end message not known (%u)\n",
            ntohs (msgh->type));
+      GMT_debug (t);
   }
 }
 

Modified: gnunet/src/mesh/mesh_path.c
===================================================================
--- gnunet/src/mesh/mesh_path.c 2013-12-17 10:05:04 UTC (rev 31473)
+++ gnunet/src/mesh/mesh_path.c 2013-12-17 12:34:35 UTC (rev 31474)
@@ -26,8 +26,28 @@
 
 #include "mesh.h"
 #include "mesh_path.h"
+#include "gnunet-service-mesh_peer.h"
 
+/**
+ * @brief Destroy a path after some time has past.
+ *
+ * If the path is returned from DHT again after a while, try again.
+ *
+ * @param cls Closure (path to destroy).
+ * @param tc Task context.
+ */
+static void
+path_destroy_delayed (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct MeshPeerPath *path = cls;
+  struct MeshPeer *peer;
 
+  path->path_delete = GNUNET_SCHEDULER_NO_TASK;
+  peer = GMP_get_short (path->peers[path->length - 1]);
+  GMP_remove_path (peer, path);
+}
+
+
 /**
  * Create a new path
  *
@@ -106,7 +126,42 @@
 }
 
 
+
 /**
+ * Mark path as invalid: keep it aroud for a while to avoid trying it in a 
loop.
+ *
+ * DHT_get sometimes returns bad cached results, for instance, on a locally
+ * cached result where the PUT followed a path that is no longer current.
+ *
+ * @param p Path to invalidate.
+ */
+void
+path_invalidate (struct MeshPeerPath *p)
+{
+  if (GNUNET_SCHEDULER_NO_TASK != p->path_delete)
+    return;
+
+  p->path_delete = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
+                                                 &path_destroy_delayed, p);
+}
+
+
+/**
+ * Test if a path is valid (or at least not known to be invalid).
+ *
+ * @param path Path to test.
+ *
+ * @return #GNUNET_YES If the path is valid or unknown,
+ *         #GNUNET_NO If the path is known to be invalid.
+ */
+int
+path_is_valid (const struct MeshPeerPath *path)
+{
+  return (GNUNET_SCHEDULER_NO_TASK == path->path_delete);
+}
+
+
+/**
  * Destroy the path and free any allocated resources linked to it
  *
  * @param p the path to destroy
@@ -118,8 +173,11 @@
 {
   if (NULL == p)
     return GNUNET_OK;
+
   GNUNET_PEER_decrement_rcs (p->peers, p->length);
   GNUNET_free_non_null (p->peers);
+  if (GNUNET_SCHEDULER_NO_TASK != p->path_delete)
+    GNUNET_SCHEDULER_cancel (p->path_delete);
   GNUNET_free (p);
   return GNUNET_OK;
 }
@@ -129,8 +187,8 @@
 {
   unsigned int i;
 
-  fprintf (stderr, "PATH:"); 
+  fprintf (stderr, "PATH:");
   for (i = 0; i < p->length; i++)
-    fprintf (stderr, "  %s", GNUNET_i2s (GNUNET_PEER_resolve2 (p->peers[i]))); 
-  fprintf (stderr, " END\n"); 
-}
\ No newline at end of file
+    fprintf (stderr, "  %s", GNUNET_i2s (GNUNET_PEER_resolve2 (p->peers[i])));
+  fprintf (stderr, " END\n");
+}

Modified: gnunet/src/mesh/mesh_path.h
===================================================================
--- gnunet/src/mesh/mesh_path.h 2013-12-17 10:05:04 UTC (rev 31473)
+++ gnunet/src/mesh/mesh_path.h 2013-12-17 12:34:35 UTC (rev 31474)
@@ -66,6 +66,12 @@
      */
   int score;
 
+  /**
+   * Task to delete the path.
+   * We tried it, it didn't work, don't try again in a while.
+   */
+  GNUNET_SCHEDULER_TaskIdentifier path_delete;
+
 };
 
 
/******************************************************************************/
@@ -112,8 +118,29 @@
 unsigned int
 path_get_length (struct MeshPeerPath *path);
 
+/**
+ * Mark path as invalid: keep it aroud for a while to avoid trying it in a 
loop.
+ *
+ * DHT_get sometimes returns bad cached results, for instance, on a locally
+ * cached result where the PUT followed a path that is no longer current.
+ *
+ * @param p Path to invalidate.
+ */
+void
+path_invalidate (struct MeshPeerPath *p);
 
 /**
+ * Test if a path is valid (or at least not known to be invalid).
+ *
+ * @param path Path to test.
+ *
+ * @return #GNUNET_YES If the path is valid or unknown,
+ *         #GNUNET_NO If the path is known to be invalid.
+ */
+int
+path_is_valid (const struct MeshPeerPath *path);
+
+/**
  * Destroy the path and free any allocated resources linked to it
  *
  * @param p the path to destroy
@@ -123,6 +150,12 @@
 int
 path_destroy (struct MeshPeerPath *p);
 
+
+/**
+ * Print info about the path for debug.
+ *
+ * @param p Path to debug.
+ */
 void
 path_debug (struct MeshPeerPath *p);
 
@@ -135,4 +168,4 @@
 
 
 /* ifndef MESH_PATH_H */
-#endif
\ No newline at end of file
+#endif




reply via email to

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