gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r28367 - gnunet/src/mesh
Date: Fri, 2 Aug 2013 02:38:02 +0200

Author: bartpolot
Date: 2013-08-02 02:38:01 +0200 (Fri, 02 Aug 2013)
New Revision: 28367

Modified:
   gnunet/src/mesh/gnunet-service-mesh-enc.c
Log:
- tunnel, connection destroy


Modified: gnunet/src/mesh/gnunet-service-mesh-enc.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh-enc.c   2013-08-02 00:26:13 UTC (rev 
28366)
+++ gnunet/src/mesh/gnunet-service-mesh-enc.c   2013-08-02 00:38:01 UTC (rev 
28367)
@@ -532,6 +532,16 @@
    * time tunnel out on all the other peers.
    */
   GNUNET_SCHEDULER_TaskIdentifier bck_maintenance_task;
+
+  /**
+   * Pending message count.
+   */
+  int pending_messages;
+
+  /**
+   * Destroy flag: if true, destroy on last message.
+   */
+  int destroy;
 };
 
 
@@ -606,6 +616,16 @@
    * Channel ID for the next incoming tunnel.
    */
   MESH_ChannelNumber next_local_chid;
+
+  /**
+   * Pending message count.
+   */
+  int pending_messages;
+
+  /**
+   * Destroy flag: if true, destroy on last message.
+   */
+  int destroy;
 };
 
 
@@ -3482,34 +3502,45 @@
 
 /**
  * Tunnel is empty: destroy it.
- * 
- * Notifies all participants (peers, cleints) about the destruction.
- * 
+ *
+ * Notifies all connections about the destruction.
+ *
  * @param t Tunnel to destroy. 
  */
 static void
-tunnel_destroy_empty (struct MeshTunnel *t)
+tunnel_destroy_empty (struct MeshTunnel2 *t)
 {
-  #if MESH_DEBUG
+  struct MeshConnection *c;
+
+  for (c = t->connection_head; NULL != c; c = c->next)
   {
-    struct GNUNET_PeerIdentity id;
-
-    GNUNET_PEER_resolve (t->id.oid, &id);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "executing destruction of empty tunnel %s [%X]\n",
-                GNUNET_i2s (&id), t->id.tid);
+    if (GNUNET_NO == c->destroy)
+      connection_send_destroy (c);
   }
-  #endif
 
-  if (GNUNET_NO == t->destroy)
-    tunnel_send_destroy (t);
   if (0 == t->pending_messages)
     tunnel_destroy (t);
   else
     t->destroy = GNUNET_YES;
 }
 
+
 /**
+ * Destroy tunnel if empty (no more channels).
+ *
+ * @param t Tunnel to destroy if empty.
+ */
+static void
+tunnel_destroy_if_empty (struct MeshTunnel2 *t)
+{
+  if (NULL != t->channel_head)
+    return;
+
+  tunnel_destroy_empty (t);
+}
+
+
+/**
  * Initialize a Flow Control structure to the initial state.
  * 
  * @param fc Flow Control structure to initialize.
@@ -3598,7 +3629,7 @@
                                            
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
   {
     GNUNET_break (0);
-    channel_destroy (t);
+    channel_destroy (ch);
     if (NULL != client)
     {
       GNUNET_break (0);
@@ -3950,6 +3981,7 @@
   struct MeshTunnel2 *t;
   struct GNUNET_PeerIdentity *dst_id;
   struct MeshFlowControl *fc;
+  struct MeshConnection *c;
   size_t data_size;
   uint32_t pid;
   uint16_t type;
@@ -4004,7 +4036,8 @@
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "*   size ok\n");
 
-  t = queue->peer->tunnel;
+  c = queue->c;
+  t = c->t;
   type = 0;
 
   /* Fill buf */
@@ -4135,6 +4168,14 @@
       fc->poll_task = GNUNET_SCHEDULER_NO_TASK;
     }
   }
+  c->pending_messages--;
+  if (GNUNET_YES == c->destroy && 0 == c->pending_messages)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "*  destroying connection!\n");
+    connection_destroy (c);
+  }
+
+  t->pending_messages--;
   if (GNUNET_YES == t->destroy && 0 == t->pending_messages)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "*  destroying tunnel!\n");
@@ -4235,6 +4276,8 @@
                                            &queue_send,
                                            dst);
   }
+  c->pending_messages++;
+  c->t->pending_messages++;
 }
 
 




reply via email to

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