From: Christian Grothoff Date: Sun, 6 May 2012 18:24:05 +0000 (+0000) Subject: -cleaner X-Git-Tag: initial-import-from-subversion-38251~13639 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e6b55e45670cb905a1fff70fbdbc48809a41315e;p=oweals%2Fgnunet.git -cleaner --- diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c index 8b163ef89..85d8b8c4d 100644 --- a/src/statistics/gnunet-statistics.c +++ b/src/statistics/gnunet-statistics.c @@ -62,6 +62,7 @@ static int watch; */ static int quiet; + /** * Callback function to process statistic values. * @@ -103,18 +104,28 @@ cleanup (void *cls, int success) FPRINTF (stderr, "%s", _("Failed to obtain statistics.\n")); ret = 1; } - if (h != NULL) + if (NULL != h) + { GNUNET_STATISTICS_destroy (h, GNUNET_NO); + h = NULL; + } } + + static void shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_STATISTICS_Handle *h = cls; + GNUNET_STATISTICS_watch_cancel (h, subsystem, name, &printer, h); - if (h != NULL) + if (NULL != h) + { GNUNET_STATISTICS_destroy (h, GNUNET_NO); + h = NULL; + } } + /** * Main function that will be run by the scheduler. * @@ -140,17 +151,18 @@ run (void *cls, char *const *args, const char *cfgfile, return; } h = GNUNET_STATISTICS_create (subsystem, cfg); - if (h == NULL) + if (NULL == h) { ret = 1; return; } GNUNET_STATISTICS_set (h, name, (uint64_t) val, persistent); GNUNET_STATISTICS_destroy (h, GNUNET_YES); + h = NULL; return; } h = GNUNET_STATISTICS_create ("gnunet-statistics", cfg); - if (h == NULL) + if (NULL == h) { ret = 1; return; diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index 6ce10421a..85eb569eb 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c @@ -412,7 +412,6 @@ reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } - /** * Task used by 'reconnect_later' to shutdown the handle * @@ -428,6 +427,7 @@ do_destroy (void *cls, GNUNET_STATISTICS_destroy (h, GNUNET_NO); } + /** * Reconnect at a later time, respecting back-off. * @@ -911,7 +911,7 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_first) } if (sync_first) { - if (h->current != NULL) + if (NULL != h->current) { if (h->current->type == ACTION_GET) { @@ -947,9 +947,9 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_first) GNUNET_CLIENT_notify_transmit_ready (h->client, h->current->msize, timeout, GNUNET_YES, &transmit_action, h); - GNUNET_assert (NULL != h->th); + GNUNET_assert (NULL != h->th); } - if (h->th != NULL) + if (NULL != h->th) return; /* do not finish destruction just yet */ } while (NULL != (pos = h->action_head))