if (GNUNET_NO != h->do_destroy)
{
h->do_destroy = GNUNET_NO;
+ if (NULL != h->destroy_task)
+ {
+ GNUNET_SCHEDULER_cancel (h->destroy_task);
+ h->destroy_task = NULL;
+ }
GNUNET_STATISTICS_destroy (h,
GNUNET_NO);
return;
* @param cls the `struct GNUNET_STATISTICS_Handle`
*/
static void
-destroy_task (void *cls)
+do_destroy (void *cls)
{
struct GNUNET_STATISTICS_Handle *h = cls;
+ h->destroy_task = NULL;
+ h->do_destroy = GNUNET_NO;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Running final destruction\n");
GNUNET_STATISTICS_destroy (h,
reconnect_later (h);
return;
}
- h->do_destroy = GNUNET_NO;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received TEST message from statistics, can complete disconnect\n");
- GNUNET_SCHEDULER_add_now (&destroy_task,
- h);
+ if (NULL != h->destroy_task)
+ GNUNET_SCHEDULER_cancel (h->destroy_task);
+ h->destroy_task = GNUNET_SCHEDULER_add_now (&do_destroy,
+ h);
}
}
-/**
- * Task used by #reconnect_later() to shutdown the handle
- *
- * @param cls the statistics handle
- */
-static void
-do_destroy (void *cls)
-{
- struct GNUNET_STATISTICS_Handle *h = cls;
-
- h->destroy_task = NULL;
- h->do_destroy = GNUNET_NO;
- GNUNET_STATISTICS_destroy (h,
- GNUNET_NO);
-}
-
-
/**
* Reconnect at a later time, respecting back-off.
*
if (GNUNET_YES == loss)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Could not save some persistent statistics\n"));
- h->do_destroy = GNUNET_NO;
if (NULL != h->destroy_task)
GNUNET_SCHEDULER_cancel (h->destroy_task);
h->destroy_task = GNUNET_SCHEDULER_add_now (&do_destroy,
if (NULL == h)
return;
- GNUNET_assert (GNUNET_NO == h->do_destroy); // Don't call twice.
+ GNUNET_assert (GNUNET_NO == h->do_destroy); /* Don't call twice. */
if ( (sync_first) &&
(GNUNET_YES == try_connect (h)) )
{
}
h->do_destroy = GNUNET_YES;
schedule_action (h);
+ GNUNET_assert (NULL == h->destroy_task);
h->destroy_task
= GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (h->backoff,
5),