-ensure stats queues do not grow too big
[oweals/gnunet.git] / src / testbed / gnunet-service-testbed_connectionpool.c
index 4ca13ed420ddfaf3738d7a085ee86ff15f475eba..0fa2a64567500eea83f96cfcc62f9d4f555bc9dc 100644 (file)
@@ -1,6 +1,6 @@
 /*
   This file is part of GNUnet.
-  Copyright (C) 2008--2015 Christian Grothoff (and other contributing authors)
+  Copyright (C) 2008--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
@@ -333,11 +333,9 @@ destroy_pooled_connection (struct PooledConnection *entry)
  * Expire a #PooledConnection object
  *
  * @param cls the #PooledConnection object
- * @param tc scheduler task context
  */
 static void
-expire (void *cls,
-        const struct GNUNET_SCHEDULER_TaskContext *tc)
+expire (void *cls)
 {
   struct PooledConnection *entry = cls;
 
@@ -429,10 +427,9 @@ search_waiting (const struct PooledConnection *entry,
  * further schedules itself if there are similar waiting objects which can be notified.
  *
  * @param cls the #PooledConnection object
- * @param tc the task context from scheduler
  */
 static void
-connection_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+connection_ready (void *cls)
 {
   struct PooledConnection *entry = cls;
   struct GST_ConnectionPool_GetHandle *gh;
@@ -975,15 +972,19 @@ GST_connection_pool_get_handle_done (struct GST_ConnectionPool_GetHandle *gh)
 {
   struct PooledConnection *entry;
 
+  if (NULL == gh)
+    return;
   entry = gh->entry;
   LOG_DEBUG ("Cleaning up get handle %p for service %u, peer %u\n",
              gh,
              gh->service, entry->index);
-  if (!gh->connection_ready_called)
+  if (! gh->connection_ready_called)
   {
-    GNUNET_CONTAINER_DLL_remove (entry->head_waiting, entry->tail_waiting, gh);
-    if ( (NULL == search_waiting (entry, entry->head_waiting))
-         && (NULL != entry->notify_task) )
+    GNUNET_CONTAINER_DLL_remove (entry->head_waiting,
+                                 entry->tail_waiting,
+                                 gh);
+    if ( (NULL == search_waiting (entry, entry->head_waiting)) &&
+         (NULL != entry->notify_task) )
     {
       GNUNET_SCHEDULER_cancel (entry->notify_task);
       entry->notify_task = NULL;
@@ -991,14 +992,18 @@ GST_connection_pool_get_handle_done (struct GST_ConnectionPool_GetHandle *gh)
   }
   if (gh->notify_waiting)
   {
-    GNUNET_CONTAINER_DLL_remove (entry->head_notify, entry->tail_notify, gh);
+    GNUNET_CONTAINER_DLL_remove (entry->head_notify,
+                                 entry->tail_notify,
+                                 gh);
     gh->notify_waiting = 0;
   }
   GNUNET_free (gh);
   gh = NULL;
-  GNUNET_assert (!entry->in_lru);
-  if (!entry->in_pool)
-    GNUNET_CONTAINER_DLL_remove (head_not_pooled, tail_not_pooled, entry);
+  GNUNET_assert (! entry->in_lru);
+  if (! entry->in_pool)
+    GNUNET_CONTAINER_DLL_remove (head_not_pooled,
+                                 tail_not_pooled,
+                                 entry);
   if (NULL != map)
   {
     if (GNUNET_YES == GNUNET_CONTAINER_multihashmap32_contains (map,