Don't pass NULL to destroy_route
[oweals/gnunet.git] / src / cadet / gnunet-service-cadet_hello.c
index 7eda3f507c9241aa8dbcf2a8f14844d9104ba4a8..3c63f3551b610bae1f881be64537b535aad7b563 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2014 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2014 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -14,8 +14,8 @@
 
      You should have received a copy of the GNU General Public License
      along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
 */
 
 #include "platform.h"
@@ -108,14 +108,11 @@ got_hello (void *cls, const struct GNUNET_PeerIdentity *id,
   LOG (GNUNET_ERROR_TYPE_DEBUG, " hello for %s (%d bytes), expires on %s\n",
        GNUNET_i2s (id), GNUNET_HELLO_size (hello),
        GNUNET_STRINGS_absolute_time_to_string (GNUNET_HELLO_get_last_expiration(hello)));
-  peer = GMP_get (id);
-  GMP_set_hello (peer, hello);
+  peer = GCP_get (id, GNUNET_YES);
+  GCP_set_hello (peer, hello);
 
-  if (GMP_get_short_id (peer) == myid)
-  {
-    mine = GMP_get_hello (peer);
-    LOG (GNUNET_ERROR_TYPE_DEBUG, " updated mine to %p\n", mine);
-  }
+  if (GCP_get_short_id (peer) == myid)
+    mine = GCP_get_hello (peer);
 }
 
 
@@ -129,7 +126,7 @@ got_hello (void *cls, const struct GNUNET_PeerIdentity *id,
  * @param c Configuration.
  */
 void
-GMH_init (const struct GNUNET_CONFIGURATION_Handle *c)
+GCH_init (const struct GNUNET_CONFIGURATION_Handle *c)
 {
   LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n");
   GNUNET_assert (NULL == nc);
@@ -142,8 +139,9 @@ GMH_init (const struct GNUNET_CONFIGURATION_Handle *c)
  * Shut down the hello subsystem.
  */
 void
-GMH_shutdown ()
+GCH_shutdown ()
 {
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down channels\n");
   if (NULL != nc)
   {
     GNUNET_PEERINFO_notify_cancel (nc);
@@ -163,9 +161,8 @@ GMH_shutdown ()
  * @return Own hello message.
  */
 const struct GNUNET_HELLO_Message *
-GMH_get_mine (void)
+GCH_get_mine (void)
 {
-  LOG (GNUNET_ERROR_TYPE_DEBUG, " mine is %p\n", mine);
   return mine;
 }
 
@@ -178,9 +175,14 @@ GMH_get_mine (void)
  * @return Hello message, if any (NULL possible).
  */
 const struct GNUNET_HELLO_Message *
-GMH_get (const struct GNUNET_PeerIdentity *id)
+GCH_get (const struct GNUNET_PeerIdentity *id)
 {
-  return GMP_get_hello (GMP_get (id));
+  struct CadetPeer *p;
+
+  p = GCP_get (id, GNUNET_NO);
+  if (NULL == p)
+    return NULL;
+  return GCP_get_hello (p);
 }
 
 
@@ -190,7 +192,7 @@ GMH_get (const struct GNUNET_PeerIdentity *id)
  * @param h Hello message.
  */
 char *
-GMH_2s (const struct GNUNET_HELLO_Message *h)
+GCH_2s (const struct GNUNET_HELLO_Message *h)
 {
   return "hello (TODO)";
 }