diff options
author | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-11-04 22:42:14 +0000 |
---|---|---|
committer | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-11-04 22:42:14 +0000 |
commit | 6043953a49bc8f8b4232d19f78532bfe21147259 (patch) | |
tree | b8a8c6fed3714f1f0deeb733cd9c7b7c3653c453 /src/statistics | |
parent | 434a30ead7cff37dc59cd82c7ffbf85bdb1a8ce8 (diff) |
-fix #2609
git-svn-id: https://gnunet.org/svn/gnunet@24696 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src/statistics')
-rw-r--r-- | src/statistics/gnunet-statistics.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c index 2331aace0c..97d8672729 100644 --- a/src/statistics/gnunet-statistics.c +++ b/src/statistics/gnunet-statistics.c @@ -73,6 +73,7 @@ static char *remote_host; */ static unsigned long long remote_port; + /** * Callback function to process statistic values. * @@ -138,17 +139,22 @@ cleanup (void *cls, int success) } +/** + * Function run on shutdown to clean up. + * + * @param cls the statistics handle + * @param tc scheduler context + */ static void shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_STATISTICS_Handle *h = cls; - if (NULL != h) - { - GNUNET_STATISTICS_watch_cancel (h, subsystem, name, &printer, h); - GNUNET_STATISTICS_destroy (h, GNUNET_NO); - h = NULL; - } + if (NULL == h) + return; + GNUNET_STATISTICS_watch_cancel (h, subsystem, name, &printer, h); + GNUNET_STATISTICS_destroy (h, GNUNET_NO); + h = NULL; } @@ -210,9 +216,7 @@ run (void *cls, char *const *args, const char *cfgfile, h = NULL; return; } - h = GNUNET_STATISTICS_create ("gnunet-statistics", cfg); - GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, h); - if (NULL == h) + if (NULL == (h = GNUNET_STATISTICS_create ("gnunet-statistics", cfg))) { ret = 1; return; @@ -229,8 +233,8 @@ run (void *cls, char *const *args, const char *cfgfile, if ((NULL == subsystem) || (NULL == name)) { printf (_("No subsystem or name given\n")); - if (h != NULL) - GNUNET_STATISTICS_destroy (h, GNUNET_NO); + GNUNET_STATISTICS_destroy (h, GNUNET_NO); + h = NULL; ret = 1; return; } @@ -241,8 +245,11 @@ run (void *cls, char *const *args, const char *cfgfile, return; } } + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, + &shutdown_task, h); } + /** * The main function to obtain statistics in GNUnet. * |