- dont return expired hellos
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh_peer.c
index 32d2513968e05248ea195793fa3c852ca7eda8c7..244839f445a99a21b3397e5ccad4db58e857f749 100644 (file)
@@ -1873,6 +1873,16 @@ GMP_set_hello (struct MeshPeer *peer, const struct GNUNET_HELLO_Message *hello)
 const struct GNUNET_HELLO_Message *
 GMP_get_hello (struct MeshPeer *peer)
 {
+  struct GNUNET_TIME_Absolute expiration;
+  struct GNUNET_TIME_Relative remaining;
+
+  expiration = GNUNET_HELLO_get_last_expiration (peer->hello);
+  remaining = GNUNET_TIME_absolute_get_remaining (expiration);
+  if (0 == remaining.rel_value_us)
+  {
+    GNUNET_free (peer->hello);
+    peer->hello = NULL;
+  }
   return peer->hello;
 }