Do not crash if key is NULL.
[oweals/gnunet.git] / src / fs / gnunet-service-fs.c
index fd776e7b836b4ce41f0100dd904bb16d2fe2c6eb..b824e6dc64105e0f028d1faa633d7a00e1c64676 100644 (file)
@@ -261,7 +261,7 @@ update_latencies (void *cls,
   }
 
   if (GNUNET_YES != active)
-       return;
+    return;
   for (i = 0; i < ats_count; i++)
   {
     if (GNUNET_ATS_QUALITY_NET_DELAY != ntohl (ats[i].type))
@@ -551,6 +551,21 @@ consider_peer_for_forwarding (void *cls, const struct GNUNET_HashCode * key,
 }
 
 
+/**
+ * Function called after the creation of a connected peer record is complete.
+ *
+ * @param cls closure (unused)
+ * @param cp handle to the newly created connected peer record
+ */
+static void
+connected_peer_cb (void *cls, struct GSF_ConnectedPeer *cp)
+{
+  if (NULL == cp)
+    return;
+  GSF_iterate_pending_requests_ (&consider_peer_for_forwarding, cp);
+}
+
+
 /**
  * Method called whenever a given peer connects.
  *
@@ -560,14 +575,9 @@ consider_peer_for_forwarding (void *cls, const struct GNUNET_HashCode * key,
 static void
 peer_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
-  struct GSF_ConnectedPeer *cp;
-
   if (0 == memcmp (&my_id, peer, sizeof (struct GNUNET_PeerIdentity)))
     return;
-  cp = GSF_peer_connect_handler_ (peer);
-  if (NULL == cp)
-    return;
-  GSF_iterate_pending_requests_ (&consider_peer_for_forwarding, cp);
+  GSF_peer_connect_handler_ (peer, &connected_peer_cb, NULL);
 }