gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r16914 - gnunet/src/mesh
Date: Fri, 16 Sep 2011 23:22:48 +0200

Author: bartpolot
Date: 2011-09-16 23:22:48 +0200 (Fri, 16 Sep 2011)
New Revision: 16914

Modified:
   gnunet/src/mesh/gnunet-service-mesh.c
Log:
Fixed creation and destrucion of trees with parent tunnel

Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c       2011-09-16 21:05:51 UTC (rev 
16913)
+++ gnunet/src/mesh/gnunet-service-mesh.c       2011-09-16 21:22:48 UTC (rev 
16914)
@@ -1412,6 +1412,27 @@
 
 
 /**
+ * Recursively destory the path tree of a tunnel.
+ * Note: it does not liberate memory for itself, parent must do it!
+ *
+ * @param n The node to destroy, along with children.
+ *
+ * @return GNUNET_OK on success
+ */
+static void
+tunnel_destroy_tree_node (struct MeshTunnelPathNode *n)
+{
+  unsigned int i;
+
+  for (i = 0; i < n->nchildren; i++)
+  {
+    tunnel_destroy_tree_node(&n->children[i]);
+  }
+  GNUNET_free (n->children);
+}
+
+
+/**
  * Destroy the tunnel and free any allocated resources linked to it
  *
  * @param t the tunnel to destroy
@@ -1458,6 +1479,11 @@
     q = qn;
     /* TODO cancel core transmit ready in case it was active */
   }
+
+  GNUNET_CONTAINER_multihashmap_destroy(t->paths->first_hops);
+  tunnel_destroy_tree_node(t->paths->root);
+  GNUNET_free(t->paths->root);
+  GNUNET_free (t->paths);
   GNUNET_free (t);
   return r;
 }
@@ -1478,7 +1504,6 @@
 {
   int r;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: D %p\n", value);
   r = tunnel_destroy ((struct MeshTunnel *) value);
   return r;
 }
@@ -2797,6 +2822,14 @@
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     return;
   }
+  t->paths = GNUNET_malloc (sizeof(struct MeshTunnelPath));
+  t->paths->first_hops = GNUNET_CONTAINER_multihashmap_create(32);
+  t->paths->t = t;
+  t->paths->root = GNUNET_malloc(sizeof(struct MeshTunnelPathNode));
+  t->paths->root->status = MESH_PEER_READY;
+  t->paths->root->t = t;
+  t->paths->root->peer = peer_info_get(&my_full_id);
+  t->paths->me = t->paths->root;
 
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
   return;




reply via email to

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