diff options
Diffstat (limited to 'src/peerinfo/gnunet-service-peerinfo.c')
-rw-r--r-- | src/peerinfo/gnunet-service-peerinfo.c | 68 |
1 files changed, 42 insertions, 26 deletions
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index a0defb8cc..66082e8f7 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c | |||
@@ -161,6 +161,16 @@ static struct NotificationContext *nc_head; | |||
161 | */ | 161 | */ |
162 | static struct NotificationContext *nc_tail; | 162 | static struct NotificationContext *nc_tail; |
163 | 163 | ||
164 | /** | ||
165 | * Handle for task to run #cron_clean_data_hosts() | ||
166 | */ | ||
167 | static struct GNUNET_SCHEDULER_Task *cron_clean; | ||
168 | |||
169 | /** | ||
170 | * Handle for task to run #cron_scan_directory_hosts() | ||
171 | */ | ||
172 | static struct GNUNET_SCHEDULER_Task *cron_scan; | ||
173 | |||
164 | 174 | ||
165 | /** | 175 | /** |
166 | * Notify all clients in the notify list about the | 176 | * Notify all clients in the notify list about the |
@@ -657,16 +667,14 @@ cron_scan_directory_data_hosts (void *cls) | |||
657 | { | 667 | { |
658 | static unsigned int retries; | 668 | static unsigned int retries; |
659 | struct DirScanContext dsc; | 669 | struct DirScanContext dsc; |
660 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
661 | 670 | ||
662 | tc = GNUNET_SCHEDULER_get_task_context (); | 671 | cron_scan = NULL; |
663 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 672 | if (GNUNET_SYSERR == |
664 | return; | 673 | GNUNET_DISK_directory_create (networkIdDirectory)) |
665 | if (GNUNET_SYSERR == GNUNET_DISK_directory_create (networkIdDirectory)) | ||
666 | { | 674 | { |
667 | GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ, | 675 | cron_scan = GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ, |
668 | GNUNET_SCHEDULER_PRIORITY_IDLE, | 676 | GNUNET_SCHEDULER_PRIORITY_IDLE, |
669 | &cron_scan_directory_data_hosts, NULL); | 677 | &cron_scan_directory_data_hosts, NULL); |
670 | return; | 678 | return; |
671 | } | 679 | } |
672 | dsc.matched = 0; | 680 | dsc.matched = 0; |
@@ -680,10 +688,10 @@ cron_scan_directory_data_hosts (void *cls) | |||
680 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, | 688 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, |
681 | _("Still no peers found in `%s'!\n"), | 689 | _("Still no peers found in `%s'!\n"), |
682 | networkIdDirectory); | 690 | networkIdDirectory); |
683 | GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ, | 691 | cron_scan = GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ, |
684 | GNUNET_SCHEDULER_PRIORITY_IDLE, | 692 | GNUNET_SCHEDULER_PRIORITY_IDLE, |
685 | &cron_scan_directory_data_hosts, | 693 | &cron_scan_directory_data_hosts, |
686 | NULL); | 694 | NULL); |
687 | } | 695 | } |
688 | 696 | ||
689 | 697 | ||
@@ -1046,11 +1054,8 @@ static void | |||
1046 | cron_clean_data_hosts (void *cls) | 1054 | cron_clean_data_hosts (void *cls) |
1047 | { | 1055 | { |
1048 | struct GNUNET_TIME_Absolute now; | 1056 | struct GNUNET_TIME_Absolute now; |
1049 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1050 | 1057 | ||
1051 | tc = GNUNET_SCHEDULER_get_task_context (); | 1058 | cron_clean = NULL; |
1052 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1053 | return; | ||
1054 | now = GNUNET_TIME_absolute_get (); | 1059 | now = GNUNET_TIME_absolute_get (); |
1055 | GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, | 1060 | GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, |
1056 | _("Cleaning up directory `%s'\n"), | 1061 | _("Cleaning up directory `%s'\n"), |
@@ -1058,9 +1063,9 @@ cron_clean_data_hosts (void *cls) | |||
1058 | GNUNET_DISK_directory_scan (networkIdDirectory, | 1063 | GNUNET_DISK_directory_scan (networkIdDirectory, |
1059 | &discard_hosts_helper, | 1064 | &discard_hosts_helper, |
1060 | &now); | 1065 | &now); |
1061 | GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ, | 1066 | cron_clean = GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ, |
1062 | &cron_clean_data_hosts, | 1067 | &cron_clean_data_hosts, |
1063 | NULL); | 1068 | NULL); |
1064 | } | 1069 | } |
1065 | 1070 | ||
1066 | 1071 | ||
@@ -1302,6 +1307,16 @@ shutdown_task (void *cls) | |||
1302 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); | 1307 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); |
1303 | stats = NULL; | 1308 | stats = NULL; |
1304 | } | 1309 | } |
1310 | if (NULL != cron_clean) | ||
1311 | { | ||
1312 | GNUNET_SCHEDULER_cancel (cron_clean); | ||
1313 | cron_clean = NULL; | ||
1314 | } | ||
1315 | if (NULL != cron_scan) | ||
1316 | { | ||
1317 | GNUNET_SCHEDULER_cancel (cron_scan); | ||
1318 | cron_scan = NULL; | ||
1319 | } | ||
1305 | } | 1320 | } |
1306 | 1321 | ||
1307 | 1322 | ||
@@ -1342,9 +1357,8 @@ run (void *cls, | |||
1342 | "USE_INCLUDED_HELLOS"); | 1357 | "USE_INCLUDED_HELLOS"); |
1343 | if (GNUNET_SYSERR == use_included) | 1358 | if (GNUNET_SYSERR == use_included) |
1344 | use_included = GNUNET_NO; | 1359 | use_included = GNUNET_NO; |
1345 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1360 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1346 | &shutdown_task, | 1361 | NULL); |
1347 | NULL); | ||
1348 | if (GNUNET_YES != noio) | 1362 | if (GNUNET_YES != noio) |
1349 | { | 1363 | { |
1350 | GNUNET_assert (GNUNET_OK == | 1364 | GNUNET_assert (GNUNET_OK == |
@@ -1358,11 +1372,13 @@ run (void *cls, | |||
1358 | return; | 1372 | return; |
1359 | } | 1373 | } |
1360 | 1374 | ||
1361 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | 1375 | cron_scan = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, |
1362 | &cron_scan_directory_data_hosts, NULL); | 1376 | &cron_scan_directory_data_hosts, |
1377 | NULL); | ||
1363 | 1378 | ||
1364 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | 1379 | cron_clean = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, |
1365 | &cron_clean_data_hosts, NULL); | 1380 | &cron_clean_data_hosts, |
1381 | NULL); | ||
1366 | if (GNUNET_YES == use_included) | 1382 | if (GNUNET_YES == use_included) |
1367 | { | 1383 | { |
1368 | ip = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); | 1384 | ip = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); |