#include "platform.h"
#include "gnunet_util_lib.h"
-#define MIN_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
+#define MAX_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
-#define MAX_FREQUENCY GNUNET_TIME_UNIT_MINUTES
+#define MIN_DELAY GNUNET_TIME_UNIT_MINUTES
/**
*/
static int do_disable_creation_time;
-/**
- * Handle for the 'shutdown' task.
- */
-static struct GNUNET_SCHEDULER_Task *kill_task;
-
/**
* Handle for the main task that does scanning and working.
*/
static void
do_stop_task (void *cls)
{
- kill_task = NULL;
do_shutdown = GNUNET_YES;
if (NULL != publish_proc)
{
/* delay by at most 4h, at least 1s, and otherwise in between depending
on how long it took to scan */
delay = GNUNET_TIME_absolute_get_duration (start_time);
- delay = GNUNET_TIME_relative_min (MIN_FREQUENCY,
- GNUNET_TIME_relative_multiply (delay,
- 100));
+ delay = GNUNET_TIME_relative_saturating_multiply (delay, 100);
+ delay = GNUNET_TIME_relative_min (delay,
+ MAX_DELAY);
delay = GNUNET_TIME_relative_max (delay,
- MAX_FREQUENCY);
+ MIN_DELAY);
run_task = GNUNET_SCHEDULER_add_delayed (delay,
&scan,
NULL);
run_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
&scan,
NULL);
- kill_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &do_stop_task,
- NULL);
+ GNUNET_SCHEDULER_add_shutdown (&do_stop_task,
+ NULL);
}