*/
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
* Call this method periodically to scan data/hosts for new hosts.
*
* @param cls unused
- * @param tc scheduler context, aborted if reason is shutdown
*/
static void
-cron_scan_directory_data_hosts (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+cron_scan_directory_data_hosts (void *cls)
{
static unsigned int retries;
struct DirScanContext dsc;
- 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);
}
* HELLOs to expire.
*
* @param cls unused
- * @param tc scheduler context, aborted if reason is shutdown
*/
static void
-cron_clean_data_hosts (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+cron_clean_data_hosts (void *cls)
{
struct GNUNET_TIME_Absolute now;
- 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);
}
* Clean up our state. Called during shutdown.
*
* @param cls unused
- * @param tc scheduler task context, unused
*/
static void
-shutdown_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls)
{
struct NotificationContext *cur;
struct NotificationContext *next;
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);