gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r35948 - gnunet/src/cadet


From: gnunet
Subject: [GNUnet-SVN] r35948 - gnunet/src/cadet
Date: Wed, 17 Jun 2015 16:27:55 +0200

Author: bartpolot
Date: 2015-06-17 16:27:55 +0200 (Wed, 17 Jun 2015)
New Revision: 35948

Modified:
   gnunet/src/cadet/gnunet-service-cadet_peer.c
Log:
- destroy peers on shutdown

Modified: gnunet/src/cadet/gnunet-service-cadet_peer.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_peer.c        2015-06-17 14:12:21 UTC 
(rev 35947)
+++ gnunet/src/cadet/gnunet-service-cadet_peer.c        2015-06-17 14:27:55 UTC 
(rev 35948)
@@ -451,8 +451,7 @@
   char own_id[16];
 
   strncpy (own_id, GNUNET_i2s (&my_full_id), 15);
-  p = GNUNET_CONTAINER_multipeermap_get (peers,
-                                         peer);
+  p = GNUNET_CONTAINER_multipeermap_get (peers, peer);
   if (NULL == p)
   {
     GNUNET_break (0);
@@ -696,8 +695,49 @@
 
 
 /**
- * Iterator over tunnel hash map entries to destroy the tunnel during shutdown.
+ * Destroy the peer_info and free any allocated resources linked to it
  *
+ * @param peer The peer_info to destroy.
+ * @return #GNUNET_OK on success
+ */
+static int
+peer_destroy (struct CadetPeer *peer)
+{
+  struct GNUNET_PeerIdentity id;
+  struct CadetPeerPath *p;
+  struct CadetPeerPath *nextp;
+
+  GNUNET_PEER_resolve (peer->id, &id);
+  GNUNET_PEER_change_rc (peer->id, -1);
+
+  LOG (GNUNET_ERROR_TYPE_INFO,
+       "destroying peer %s\n",
+       GNUNET_i2s (&id));
+
+  if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_remove (peers, &id, peer))
+  {
+    GNUNET_break (0);
+    LOG (GNUNET_ERROR_TYPE_WARNING, " peer not in peermap!!\n");
+  }
+  GCP_stop_search (peer);
+  p = peer->path_head;
+  while (NULL != p)
+  {
+    nextp = p->next;
+    GNUNET_CONTAINER_DLL_remove (peer->path_head, peer->path_tail, p);
+    path_destroy (p);
+    p = nextp;
+  }
+  if (NULL != peer->tunnel)
+    GCT_destroy_empty (peer->tunnel);
+  GNUNET_free (peer);
+  return GNUNET_OK;
+}
+
+
+/**
+ * Iterator over peer hash map entries to destroy the peer during shutdown.
+ *
  * @param cls closure
  * @param key current key code
  * @param value value in the hash map
@@ -705,9 +745,9 @@
  *         #GNUNET_NO if not.
  */
 static int
-shutdown_tunnel (void *cls,
-                 const struct GNUNET_PeerIdentity *key,
-                 void *value)
+shutdown_peer (void *cls,
+               const struct GNUNET_PeerIdentity *key,
+               void *value)
 {
   struct CadetPeer *p = value;
   struct CadetTunnel *t = p->tunnel;
@@ -714,6 +754,8 @@
 
   if (NULL != t)
     GCT_destroy (t);
+  p->tunnel = NULL;
+  peer_destroy (p);
   return GNUNET_YES;
 }
 
@@ -755,49 +797,6 @@
 
 
 /**
- * Destroy the peer_info and free any allocated resources linked to it
- *
- * @param peer The peer_info to destroy.
- * @return #GNUNET_OK on success
- */
-static int
-peer_destroy (struct CadetPeer *peer)
-{
-  struct GNUNET_PeerIdentity id;
-  struct CadetPeerPath *p;
-  struct CadetPeerPath *nextp;
-
-  GNUNET_PEER_resolve (peer->id, &id);
-  GNUNET_PEER_change_rc (peer->id, -1);
-
-  LOG (GNUNET_ERROR_TYPE_WARNING,
-       "destroying peer %s\n",
-       GNUNET_i2s (&id));
-
-  if (GNUNET_YES !=
-    GNUNET_CONTAINER_multipeermap_remove (peers,
-                                          &id,
-                                          peer))
-  {
-    GNUNET_break (0);
-    LOG (GNUNET_ERROR_TYPE_WARNING, " not in peermap!!\n");
-  }
-  GCP_stop_search (peer);
-  p = peer->path_head;
-  while (NULL != p)
-  {
-    nextp = p->next;
-    GNUNET_CONTAINER_DLL_remove (peer->path_head, peer->path_tail, p);
-    path_destroy (p);
-    p = nextp;
-  }
-  GCT_destroy_empty (peer->tunnel);
-  GNUNET_free (peer);
-  return GNUNET_OK;
-}
-
-
-/**
  * Returns if peer is used (has a tunnel or is neighbor).
  *
  * @param peer Peer to check.
@@ -1720,7 +1719,7 @@
 GCP_shutdown (void)
 {
   GNUNET_CONTAINER_multipeermap_iterate (peers,
-                                         &shutdown_tunnel,
+                                         &shutdown_peer,
                                          NULL);
   if (NULL != core_handle)
   {




reply via email to

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