- give out run handle through which master controller's handle can be retrieved
[oweals/gnunet.git] / src / testbed / gnunet-service-testbed_cache.c
index 4a600b93180a1b270d558bad7e9492eaaebdbec1..6a141a2525727dc75adebd2c92ce99b84c674dff 100644 (file)
@@ -1,10 +1,10 @@
 /*
   This file is part of GNUnet.
 /*
   This file is part of GNUnet.
-  (C) 2012 Christian Grothoff (and other contributing authors)
+  (C) 2008--2013 Christian Grothoff (and other contributing authors)
 
   GNUnet is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published
 
   GNUnet is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published
-  by the Free Software Foundation; either version 2, or (at your
+  by the Free Software Foundation; either version 3, or (at your
   option) any later version.
 
   GNUnet is distributed in the hope that it will be useful, but
   option) any later version.
 
   GNUnet is distributed in the hope that it will be useful, but
@@ -540,8 +540,6 @@ peer_connect_notify_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
  *
  * @param cls closure
  * @param peer the peer that connected
  *
  * @param cls closure
  * @param peer the peer that connected
- * @param ats performance data
- * @param ats_count number of entries in ats (excluding 0-termination)
  */
 static void
 transport_peer_connect_notify_cb (void *cls,
  */
 static void
 transport_peer_connect_notify_cb (void *cls,
@@ -609,11 +607,10 @@ oprelease_get_handle_transport (void *cls)
  * do this later).
  *
  * @param cls closure
  * do this later).
  *
  * @param cls closure
- * @param server handle to the server, NULL if we failed
  * @param my_identity ID of this peer, NULL if we failed
  */
 static void
  * @param my_identity ID of this peer, NULL if we failed
  */
 static void
-core_startup_cb (void *cls, struct GNUNET_CORE_Handle *server,
+core_startup_cb (void *cls, 
                  const struct GNUNET_PeerIdentity *my_identity)
 {
   struct CacheEntry *entry = cls;
                  const struct GNUNET_PeerIdentity *my_identity)
 {
   struct CacheEntry *entry = cls;
@@ -624,9 +621,8 @@ core_startup_cb (void *cls, struct GNUNET_CORE_Handle *server,
     return;
   }
   GNUNET_assert (NULL == entry->peer_identity);
     return;
   }
   GNUNET_assert (NULL == entry->peer_identity);
-  GNUNET_break (NULL != server);
-  entry->core_handle = server;
-  entry->peer_identity = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
+  // FIXME: why is this dynamically allocated?
+  entry->peer_identity = GNUNET_new (struct GNUNET_PeerIdentity);
   memcpy (entry->peer_identity, my_identity,
           sizeof (struct GNUNET_PeerIdentity));
   if (0 == entry->demand)
   memcpy (entry->peer_identity, my_identity,
           sizeof (struct GNUNET_PeerIdentity));
   if (0 == entry->demand)
@@ -643,13 +639,9 @@ core_startup_cb (void *cls, struct GNUNET_CORE_Handle *server,
  *
  * @param cls closure
  * @param peer peer identity this notification is about
  *
  * @param cls closure
  * @param peer peer identity this notification is about
- * @param atsi performance data for the connection
- * @param atsi_count number of records in 'atsi'
  */
 static void
  */
 static void
-core_peer_connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
-                      const struct GNUNET_ATS_Information *atsi,
-                      unsigned int atsi_count)
+core_peer_connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
   peer_connect_notify_cb (cls, peer, CGT_CORE_HANDLE);
 }
 {
   peer_connect_notify_cb (cls, peer, CGT_CORE_HANDLE);
 }
@@ -799,6 +791,7 @@ cache_get_handle (unsigned int peer_id, struct GSTCacheGetHandle *cgh,
     }
     return cgh;
   }
     }
     return cgh;
   }
+  op = NULL;
   switch (cgh->type)
   {
   case CGT_TRANSPORT_HANDLE:
   switch (cgh->type)
   {
   case CGT_TRANSPORT_HANDLE:
@@ -815,6 +808,8 @@ cache_get_handle (unsigned int peer_id, struct GSTCacheGetHandle *cgh,
                                            &oprelease_get_handle_core);
     entry->core_op = op;
     break;
                                            &oprelease_get_handle_core);
     entry->core_op = op;
     break;
+  default:
+    GNUNET_assert (0);
   }
   GNUNET_TESTBED_operation_queue_insert_ (GST_opq_openfds, op);
   GNUNET_TESTBED_operation_begin_wait_ (op);
   }
   GNUNET_TESTBED_operation_queue_insert_ (GST_opq_openfds, op);
   GNUNET_TESTBED_operation_begin_wait_ (op);
@@ -841,7 +836,8 @@ cache_clear_iterator (void *cls, const struct GNUNET_HashCode *key, void *value)
   GNUNET_assert (NULL != entry);
   GNUNET_break (0 == entry->demand);
   LOG_DEBUG ("Clearing entry %u of %u\n", ++ncleared, cache_size);
   GNUNET_assert (NULL != entry);
   GNUNET_break (0 == entry->demand);
   LOG_DEBUG ("Clearing entry %u of %u\n", ++ncleared, cache_size);
-  GNUNET_CONTAINER_multihashmap_remove (cache, key, value);
+  GNUNET_assert (GNUNET_YES == 
+                 GNUNET_CONTAINER_multihashmap_remove (cache, key, value));
   close_handles (entry);
   GNUNET_free_non_null (entry->hello);
   GNUNET_break (GNUNET_SCHEDULER_NO_TASK == entry->expire_task);
   close_handles (entry);
   GNUNET_free_non_null (entry->hello);
   GNUNET_break (GNUNET_SCHEDULER_NO_TASK == entry->expire_task);
@@ -936,9 +932,7 @@ GST_cache_get_handle_done (struct GSTCacheGetHandle *cgh)
   }
   else
   {
   }
   else
   {
-    struct GSTCacheGetHandle *cgh2;
-
-    if (NULL != (cgh2 = search_suitable_cgh (entry, entry->cgh_qhead)))
+    if (NULL != search_suitable_cgh (entry, entry->cgh_qhead))
       entry->notify_task = GNUNET_SCHEDULER_add_now (&call_cgh_cb, entry);
   }
 }
       entry->notify_task = GNUNET_SCHEDULER_add_now (&call_cgh_cb, entry);
   }
 }