From: Bart Polot Date: Tue, 8 May 2012 13:33:51 +0000 (+0000) Subject: - Document statistics api and fix testing's usage of it X-Git-Tag: initial-import-from-subversion-38251~13603 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b7d2254d7c2b838f8b52b36d05210bab5fe3bae9;p=oweals%2Fgnunet.git - Document statistics api and fix testing's usage of it --- diff --git a/src/include/gnunet_statistics_service.h b/src/include/gnunet_statistics_service.h index bfd65f883..051533182 100644 --- a/src/include/gnunet_statistics_service.h +++ b/src/include/gnunet_statistics_service.h @@ -145,6 +145,7 @@ struct GNUNET_STATISTICS_GetHandle; * @param timeout after how long should we give up (and call * notify with buf NULL and size 0)? * @param cont continuation to call when done (can be NULL) + * This callback CANNOT destroy the statistics handle in the same call. * @param proc function to call on each value * @param cls closure for proc and cont * @return NULL on error diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index 0533ff950..e1b3698e6 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c @@ -1075,6 +1075,7 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h) * @param timeout after how long should we give up (and call * cont with an error code)? * @param cont continuation to call when done (can be NULL) + * This callback CANNOT destroy the statistics handle in the same call. * @param proc function to call on each value * @param cls closure for cont and proc * @return NULL on error diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 607d455b6..40cab604b 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c @@ -4884,6 +4884,22 @@ internal_stats_callback (void *cls, const char *subsystem, const char *name, subsystem, name, value, is_persistent); } + +/** + * We don't need the statistics handle anymore, destroy it. + * + * @param cls Closure (the statistics handle to destroy) + * @param tc Task Context + */ +static void +internal_destroy_statistics (void *cls, GNUNET_SCHEDULER_TaskContext *tc) +{ + struct GNUNET_STATISTICS_Handle *h = cls; + + GNUNET_STATISTICS_destroy (h, GNUNET_NO); +} + + /** * Internal continuation call for statistics iteration. * @@ -4908,7 +4924,9 @@ internal_stats_cont (void *cls, int success) } if (core_context->stats_handle != NULL) - GNUNET_STATISTICS_destroy (core_context->stats_handle, GNUNET_NO); + /* Cannot destroy handle inside the continuation */ + GNUNET_SCHEDULER_add_now (&internal_destroy_statistics, + core_context->stats_handle); GNUNET_free (core_context); } @@ -5290,9 +5308,9 @@ increment_outstanding_at_host (const char *hostname, struct OutstandingSSH *pos; pos = pg->ssh_head; - while ((pos != NULL) && (strcmp (pos->hostname, hostname) != 0)) + while ((NULL != pos) && (strcmp (pos->hostname, hostname) != 0)) pos = pos->next; - GNUNET_assert (pos != NULL); + GNUNET_assert (NULL != pos); pos->outstanding++; }