-fix off-by-1
[oweals/gnunet.git] / src / dht / gnunet-service-dht_neighbours.c
index 487cec375a049e93323d3057f44e69bd7df72007..773ad8983c0748ad052ae774055615c78369bf50 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2009-2015 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2009-2015 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
@@ -492,11 +492,9 @@ find_bucket (const struct GNUNET_HashCode *hc)
  * Clean up the "oh" field in the @a cls
  *
  * @param cls a `struct ConnectInfo`
- * @param tc unused
  */
 static void
-offer_hello_done (void *cls,
-                  const struct GNUNET_SCHEDULER_TaskContext *tc)
+offer_hello_done (void *cls)
 {
   struct ConnectInfo *ci = cls;
 
@@ -517,7 +515,7 @@ free_connect_info (void *cls,
                    const struct GNUNET_PeerIdentity *peer,
                    void *value)
 {
-  struct ConnectInfo *ci = cls;
+  struct ConnectInfo *ci = value;
 
   GNUNET_assert (GNUNET_YES ==
                  GNUNET_CONTAINER_multipeermap_remove (all_desired_peers,
@@ -707,19 +705,15 @@ add_known_to_bloom (void *cls,
  * and attempt to connect to them.
  *
  * @param cls closure for this task
- * @param tc the context under which the task is running
  */
 static void
-send_find_peer_message (void *cls,
-                        const struct GNUNET_SCHEDULER_TaskContext *tc)
+send_find_peer_message (void *cls)
 {
   struct GNUNET_TIME_Relative next_send_time;
   struct BloomConstructorContext bcc;
   struct GNUNET_CONTAINER_BloomFilter *peer_bf;
 
   find_peer_task = NULL;
-  if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
-    return;
   if (newly_found_peers > bucket_size)
   {
     /* If we are finding many peers already, no need to send out our request right now! */
@@ -758,8 +752,10 @@ send_find_peer_message (void *cls,
                                 DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value_us /
                                 (newly_found_peers + 1));
   newly_found_peers = 0;
+  GNUNET_assert (NULL == find_peer_task);
   find_peer_task =
-      GNUNET_SCHEDULER_add_delayed (next_send_time, &send_find_peer_message,
+      GNUNET_SCHEDULER_add_delayed (next_send_time,
+                                    &send_find_peer_message,
                                     NULL);
 }
 
@@ -827,6 +823,7 @@ handle_core_connect (void *cls,
       (GNUNET_YES != disable_try_connect))
   {
     /* got a first connection, good time to start with FIND PEER requests... */
+    GNUNET_assert (NULL == find_peer_task);
     find_peer_task = GNUNET_SCHEDULER_add_now (&send_find_peer_message,
                                                NULL);
   }
@@ -2445,6 +2442,7 @@ GDS_NEIGHBOURS_done ()
   }
 }
 
+
 /**
  * Get the ID of the local node.
  *