gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r31817 - gnunet/src/mesh
Date: Tue, 7 Jan 2014 10:38:22 +0100

Author: bartpolot
Date: 2014-01-07 10:38:22 +0100 (Tue, 07 Jan 2014)
New Revision: 31817

Modified:
   gnunet/src/mesh/gnunet-service-mesh_tunnel.c
Log:
- delay tunnel destruction 1 min to avoid rekeying


Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.c        2014-01-07 09:31:13 UTC 
(rev 31816)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.c        2014-01-07 09:38:22 UTC 
(rev 31817)
@@ -136,7 +136,7 @@
   /**
    * Destroy flag: if true, destroy on last message.
    */
-  int destroy;
+  GNUNET_SCHEDULER_TaskIdentifier destroy_task;
 
   /**
    * Queued messages, to transmit once tunnel gets connected.
@@ -779,7 +779,8 @@
   c = tunnel_get_connection (t);
   if (NULL == c)
   {
-    if (GNUNET_YES == t->destroy || MESH_TUNNEL3_SEARCHING != t->cstate)
+    if (GNUNET_SCHEDULER_NO_TASK != t->destroy_task
+        || MESH_TUNNEL3_SEARCHING != t->cstate)
     {
       GNUNET_break (0);
       GMT_debug (t);
@@ -905,7 +906,7 @@
     return;
   }
 
-  if (GNUNET_NO != t->destroy)
+  if (GNUNET_SCHEDULER_NO_TASK != t->destroy_task)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "  being destroyed, why bother\n");
     return;
@@ -925,7 +926,8 @@
   c = tunnel_get_connection (t);
   if (NULL == c)
   {
-    GNUNET_break (GNUNET_YES == t->destroy || MESH_TUNNEL3_READY != t->cstate);
+    GNUNET_break (GNUNET_SCHEDULER_NO_TASK != t->destroy_task
+                  || MESH_TUNNEL3_READY != t->cstate);
     GMT_debug (t);
     return;
   }
@@ -1869,7 +1871,7 @@
 
   /* Start new connections if needed */
   if (NULL == t->connection_head
-      && GNUNET_NO == t->destroy
+      && GNUNET_SCHEDULER_NO_TASK == t->destroy_task
       && GNUNET_NO == shutting_down)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "  no more connections, getting new ones\n");
@@ -1918,9 +1920,10 @@
   LOG (GNUNET_ERROR_TYPE_DEBUG, " adding %p to %p\n", aux, t->channel_head);
   GNUNET_CONTAINER_DLL_insert_tail (t->channel_head, t->channel_tail, aux);
 
-  if (GNUNET_YES == t->destroy)
+  if (GNUNET_SCHEDULER_NO_TASK != t->destroy_task)
   {
-    t->destroy = GNUNET_NO;
+    GNUNET_SCHEDULER_cancel (t->destroy_task);
+    t->destroy_task = GNUNET_SCHEDULER_NO_TASK;
     LOG (GNUNET_ERROR_TYPE_DEBUG, " undo destroy!\n");
   }
 }
@@ -1978,6 +1981,25 @@
 
 
 /**
+ * @brief Destroy a tunnel and free all resources.
+ *
+ * Should only be called a while after the tunnel has been marked as destroyed,
+ * in case there is a new channel added to the same peer shortly after marking
+ * the tunnel. This way we avoid a new public key handshake.
+ *
+ * @param cls Closure (tunnel to destroy).
+ * @param tc Task context.
+ */
+static void
+tunnel_destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct MeshTunnel3 *t = cls;
+
+  GMT_destroy (t);
+}
+
+
+/**
  * Tunnel is empty: destroy it.
  *
  * Notifies all connections about the destruction.
@@ -2005,7 +2027,8 @@
     t->kx_ctx = NULL;
   }
   t->cstate = MESH_TUNNEL3_NEW;
-  t->destroy = GNUNET_YES;
+  t->destroy_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
+                                                  &tunnel_destroy, t);
 }
 
 
@@ -2046,7 +2069,11 @@
   if (NULL == t)
     return;
 
-  t->destroy = 2;
+  if (GNUNET_SCHEDULER_NO_TASK != t->destroy_task)
+  {
+    GNUNET_SCHEDULER_cancel (t->destroy_task);
+    t->destroy_task = GNUNET_SCHEDULER_NO_TASK;
+  }
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying tunnel %s\n", GMP_2s (t->peer));
 
@@ -2598,7 +2625,7 @@
        t->kx_ctx, t->rekey_task);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "  tq_head %p, tq_tail %p\n",
        t->tq_head, t->tq_tail);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "  destroy %u\n", t->destroy);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "  destroy %u\n", t->destroy_task);
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, "  channels:\n");
   for (iterch = t->channel_head; NULL != iterch; iterch = iterch->next)




reply via email to

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