naming
[oweals/gnunet.git] / src / dht / gnunet-service-dht_hello.c
index 2ee60c91f6449aaad429645ab4a58ff70406c4ca..5be0cbfec1c3b74dab482605519d521e3abba10d 100644 (file)
@@ -52,6 +52,8 @@ static struct GNUNET_CONTAINER_MultiHashMap *peer_to_hello;
 const struct GNUNET_HELLO_Message *
 GDS_HELLO_get (const struct GNUNET_PeerIdentity *peer)
 {
+  if (NULL == peer_to_hello)
+    return NULL;
   return GNUNET_CONTAINER_multihashmap_get (peer_to_hello,
                                            &peer->hashPubKey);
 }
@@ -80,6 +82,9 @@ process_hello (void *cls,
   ex = GNUNET_HELLO_get_last_expiration (hello);
   if (GNUNET_TIME_absolute_get_remaining (ex).rel_value == 0)
     return;
+  GNUNET_STATISTICS_update (GDS_stats,
+                           gettext_noop ("# HELLOs obtained from peerinfo"), 1,
+                           GNUNET_NO);
   hm = GNUNET_CONTAINER_multihashmap_get (peer_to_hello,
                                          &peer->hashPubKey);
   GNUNET_free_non_null (hm);
@@ -130,10 +135,13 @@ GDS_HELLO_done ()
     GNUNET_PEERINFO_notify_cancel (pnc);
     pnc = NULL;
   }
-  GNUNET_CONTAINER_multihashmap_iterate (peer_to_hello,
-                                        &free_hello,
-                                        NULL);
-  GNUNET_CONTAINER_multihashmap_destroy (peer_to_hello);
+  if (NULL != peer_to_hello)
+  {
+    GNUNET_CONTAINER_multihashmap_iterate (peer_to_hello,
+                                          &free_hello,
+                                          NULL);
+    GNUNET_CONTAINER_multihashmap_destroy (peer_to_hello);
+  }
 }
 
 /* end of gnunet-service-dht_hello.c */