*/
static struct NotificationContext *nc_tail;
+/**
+ * Handle for task to run #cron_clean_data_hosts()
+ */
+static struct GNUNET_SCHEDULER_Task *cron_clean;
+
+/**
+ * Handle for task to run #cron_scan_directory_hosts()
+ */
+static struct GNUNET_SCHEDULER_Task *cron_scan;
+
/**
* Notify all clients in the notify list about the
{
static unsigned int retries;
struct DirScanContext dsc;
- const struct GNUNET_SCHEDULER_TaskContext *tc;
- tc = GNUNET_SCHEDULER_get_task_context ();
- if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
- return;
- if (GNUNET_SYSERR == GNUNET_DISK_directory_create (networkIdDirectory))
+ cron_scan = NULL;
+ if (GNUNET_SYSERR ==
+ GNUNET_DISK_directory_create (networkIdDirectory))
{
- GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ,
- GNUNET_SCHEDULER_PRIORITY_IDLE,
- &cron_scan_directory_data_hosts, NULL);
+ cron_scan = GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ,
+ GNUNET_SCHEDULER_PRIORITY_IDLE,
+ &cron_scan_directory_data_hosts, NULL);
return;
}
dsc.matched = 0;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
_("Still no peers found in `%s'!\n"),
networkIdDirectory);
- GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ,
- GNUNET_SCHEDULER_PRIORITY_IDLE,
- &cron_scan_directory_data_hosts,
- NULL);
+ cron_scan = GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ,
+ GNUNET_SCHEDULER_PRIORITY_IDLE,
+ &cron_scan_directory_data_hosts,
+ NULL);
}
cron_clean_data_hosts (void *cls)
{
struct GNUNET_TIME_Absolute now;
- const struct GNUNET_SCHEDULER_TaskContext *tc;
- tc = GNUNET_SCHEDULER_get_task_context ();
- if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
- return;
+ cron_clean = NULL;
now = GNUNET_TIME_absolute_get ();
GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
_("Cleaning up directory `%s'\n"),
GNUNET_DISK_directory_scan (networkIdDirectory,
&discard_hosts_helper,
&now);
- GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ,
- &cron_clean_data_hosts,
- NULL);
+ cron_clean = GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ,
+ &cron_clean_data_hosts,
+ NULL);
}
GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
stats = NULL;
}
+ if (NULL != cron_clean)
+ {
+ GNUNET_SCHEDULER_cancel (cron_clean);
+ cron_clean = NULL;
+ }
+ if (NULL != cron_scan)
+ {
+ GNUNET_SCHEDULER_cancel (cron_scan);
+ cron_scan = NULL;
+ }
}
"USE_INCLUDED_HELLOS");
if (GNUNET_SYSERR == use_included)
use_included = GNUNET_NO;
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &shutdown_task,
- NULL);
+ GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+ NULL);
if (GNUNET_YES != noio)
{
GNUNET_assert (GNUNET_OK ==
return;
}
- GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
- &cron_scan_directory_data_hosts, NULL);
+ cron_scan = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
+ &cron_scan_directory_data_hosts,
+ NULL);
- GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
- &cron_clean_data_hosts, NULL);
+ cron_clean = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
+ &cron_clean_data_hosts,
+ NULL);
if (GNUNET_YES == use_included)
{
ip = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);