*/
static int ok;
+/**
+ * Identifier for the churn task that runs periodically
+ */
+static struct GNUNET_SCHEDULER_Task *shutdown_task;
+
/**
* Identifier for the churn task that runs periodically
*/
if (0 == evaluate ())
{
- GNUNET_SCHEDULER_shutdown ();
+ GNUNET_assert (NULL != shutdown_task);
+ GNUNET_SCHEDULER_cancel (shutdown_task);
+ shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL);
+ GNUNET_assert (NULL!= shutdown_task);
}
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Churn function executing\n");
+ churn_task = NULL; /* Should be invalid by now */
+
/* Compute the probability for an online peer to go offline
* this round */
portion_online = num_peers_online * 1.0 / num_peers;
if (NULL != churn_task)
GNUNET_SCHEDULER_cancel (churn_task);
- GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL);
+ shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL);
}