diff options
Diffstat (limited to 'src/hostlist/hostlist-client.c')
-rw-r--r-- | src/hostlist/hostlist-client.c | 52 |
1 files changed, 15 insertions, 37 deletions
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index e41c8ff18..47d625437 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c | |||
@@ -109,11 +109,6 @@ struct Hostlist | |||
109 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 109 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * Our scheduler. | ||
113 | */ | ||
114 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
115 | |||
116 | /** | ||
117 | * Statistics handle. | 112 | * Statistics handle. |
118 | */ | 113 | */ |
119 | static struct GNUNET_STATISTICS_Handle *stats; | 114 | static struct GNUNET_STATISTICS_Handle *stats; |
@@ -769,8 +764,7 @@ download_prepare () | |||
769 | "Scheduling task for hostlist download using cURL\n"); | 764 | "Scheduling task for hostlist download using cURL\n"); |
770 | #endif | 765 | #endif |
771 | ti_download | 766 | ti_download |
772 | = GNUNET_SCHEDULER_add_select (sched, | 767 | = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
773 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | ||
774 | GNUNET_SCHEDULER_NO_TASK, | 768 | GNUNET_SCHEDULER_NO_TASK, |
775 | rtime, | 769 | rtime, |
776 | grs, | 770 | grs, |
@@ -1036,8 +1030,7 @@ task_download_dispatcher (void *cls, | |||
1036 | { | 1030 | { |
1037 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1031 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1038 | "Download in progess, have to wait...\n"); | 1032 | "Download in progess, have to wait...\n"); |
1039 | ti_download_dispatcher_task = GNUNET_SCHEDULER_add_delayed (sched, | 1033 | ti_download_dispatcher_task = GNUNET_SCHEDULER_add_delayed (WAITING_INTERVALL, |
1040 | WAITING_INTERVALL, | ||
1041 | &task_download_dispatcher, | 1034 | &task_download_dispatcher, |
1042 | NULL); | 1035 | NULL); |
1043 | } | 1036 | } |
@@ -1061,8 +1054,7 @@ task_check (void *cls, | |||
1061 | 1054 | ||
1062 | if (stat_connection_count < MIN_CONNECTIONS) | 1055 | if (stat_connection_count < MIN_CONNECTIONS) |
1063 | { | 1056 | { |
1064 | ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now ( sched, | 1057 | ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (&task_download_dispatcher, |
1065 | &task_download_dispatcher, | ||
1066 | NULL); | 1058 | NULL); |
1067 | } | 1059 | } |
1068 | 1060 | ||
@@ -1093,8 +1085,7 @@ task_check (void *cls, | |||
1093 | stat_connection_count, | 1085 | stat_connection_count, |
1094 | MIN_CONNECTIONS, | 1086 | MIN_CONNECTIONS, |
1095 | (unsigned long long) delay.rel_value); | 1087 | (unsigned long long) delay.rel_value); |
1096 | ti_check_download = GNUNET_SCHEDULER_add_delayed (sched, | 1088 | ti_check_download = GNUNET_SCHEDULER_add_delayed (delay, |
1097 | delay, | ||
1098 | &task_check, | 1089 | &task_check, |
1099 | NULL); | 1090 | NULL); |
1100 | } | 1091 | } |
@@ -1136,8 +1127,7 @@ task_hostlist_saving (void *cls, | |||
1136 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1127 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1137 | _("Hostlists will be saved to file again in %llums\n"), | 1128 | _("Hostlists will be saved to file again in %llums\n"), |
1138 | (unsigned long long) SAVING_INTERVALL.rel_value); | 1129 | (unsigned long long) SAVING_INTERVALL.rel_value); |
1139 | ti_saving_task = GNUNET_SCHEDULER_add_delayed (sched, | 1130 | ti_saving_task = GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, |
1140 | SAVING_INTERVALL, | ||
1141 | &task_hostlist_saving, | 1131 | &task_hostlist_saving, |
1142 | NULL); | 1132 | NULL); |
1143 | } | 1133 | } |
@@ -1259,8 +1249,7 @@ handler_advertisement (void *cls, | |||
1259 | 1249 | ||
1260 | stat_testing_hostlist = GNUNET_YES; | 1250 | stat_testing_hostlist = GNUNET_YES; |
1261 | stat_testing_allowed = GNUNET_NO; | 1251 | stat_testing_allowed = GNUNET_NO; |
1262 | ti_testing_intervall_task = GNUNET_SCHEDULER_add_delayed (sched, | 1252 | ti_testing_intervall_task = GNUNET_SCHEDULER_add_delayed (TESTING_INTERVAL, |
1263 | TESTING_INTERVAL, | ||
1264 | &task_testing_intervall_reset, | 1253 | &task_testing_intervall_reset, |
1265 | NULL); | 1254 | NULL); |
1266 | 1255 | ||
@@ -1268,8 +1257,7 @@ handler_advertisement (void *cls, | |||
1268 | "Testing new hostlist advertisements is locked for the next %u ms\n", | 1257 | "Testing new hostlist advertisements is locked for the next %u ms\n", |
1269 | TESTING_INTERVAL.rel_value); | 1258 | TESTING_INTERVAL.rel_value); |
1270 | 1259 | ||
1271 | ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (sched, | 1260 | ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (&task_download_dispatcher, |
1272 | &task_download_dispatcher, | ||
1273 | NULL); | 1261 | NULL); |
1274 | 1262 | ||
1275 | return GNUNET_OK; | 1263 | return GNUNET_OK; |
@@ -1294,8 +1282,7 @@ primary_task (void *cls, int success) | |||
1294 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1282 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1295 | "Statistics request done, scheduling hostlist download\n"); | 1283 | "Statistics request done, scheduling hostlist download\n"); |
1296 | #endif | 1284 | #endif |
1297 | ti_check_download = GNUNET_SCHEDULER_add_now (sched, | 1285 | ti_check_download = GNUNET_SCHEDULER_add_now (&task_check, |
1298 | &task_check, | ||
1299 | NULL); | 1286 | NULL); |
1300 | } | 1287 | } |
1301 | 1288 | ||
@@ -1502,7 +1489,6 @@ static void save_hostlist_file ( int shutdown ) | |||
1502 | */ | 1489 | */ |
1503 | int | 1490 | int |
1504 | GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | 1491 | GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, |
1505 | struct GNUNET_SCHEDULER_Handle *s, | ||
1506 | struct GNUNET_STATISTICS_Handle *st, | 1492 | struct GNUNET_STATISTICS_Handle *st, |
1507 | GNUNET_CORE_ConnectEventHandler *ch, | 1493 | GNUNET_CORE_ConnectEventHandler *ch, |
1508 | GNUNET_CORE_DisconnectEventHandler *dh, | 1494 | GNUNET_CORE_DisconnectEventHandler *dh, |
@@ -1517,14 +1503,13 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1517 | GNUNET_break (0); | 1503 | GNUNET_break (0); |
1518 | return GNUNET_SYSERR; | 1504 | return GNUNET_SYSERR; |
1519 | } | 1505 | } |
1520 | transport = GNUNET_TRANSPORT_connect (s, c, NULL, NULL, NULL, NULL, NULL); | 1506 | transport = GNUNET_TRANSPORT_connect (c, NULL, NULL, NULL, NULL, NULL); |
1521 | if (NULL == transport) | 1507 | if (NULL == transport) |
1522 | { | 1508 | { |
1523 | curl_global_cleanup (); | 1509 | curl_global_cleanup (); |
1524 | return GNUNET_SYSERR; | 1510 | return GNUNET_SYSERR; |
1525 | } | 1511 | } |
1526 | cfg = c; | 1512 | cfg = c; |
1527 | sched = s; | ||
1528 | stats = st; | 1513 | stats = st; |
1529 | if (GNUNET_OK != | 1514 | if (GNUNET_OK != |
1530 | GNUNET_CONFIGURATION_get_value_string (cfg, | 1515 | GNUNET_CONFIGURATION_get_value_string (cfg, |
@@ -1550,8 +1535,7 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1550 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1535 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1551 | _("Hostlists will be saved to file again in %llums\n"), | 1536 | _("Hostlists will be saved to file again in %llums\n"), |
1552 | (unsigned long long) SAVING_INTERVALL.rel_value); | 1537 | (unsigned long long) SAVING_INTERVALL.rel_value); |
1553 | ti_saving_task = GNUNET_SCHEDULER_add_delayed (sched, | 1538 | ti_saving_task = GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, |
1554 | SAVING_INTERVALL, | ||
1555 | &task_hostlist_saving, | 1539 | &task_hostlist_saving, |
1556 | NULL); | 1540 | NULL); |
1557 | } | 1541 | } |
@@ -1606,29 +1590,24 @@ GNUNET_HOSTLIST_client_stop () | |||
1606 | 1590 | ||
1607 | if (ti_saving_task != GNUNET_SCHEDULER_NO_TASK) | 1591 | if (ti_saving_task != GNUNET_SCHEDULER_NO_TASK) |
1608 | { | 1592 | { |
1609 | GNUNET_SCHEDULER_cancel (sched, | 1593 | GNUNET_SCHEDULER_cancel (ti_saving_task); |
1610 | ti_saving_task); | ||
1611 | } | 1594 | } |
1612 | 1595 | ||
1613 | if (ti_download_dispatcher_task != GNUNET_SCHEDULER_NO_TASK) | 1596 | if (ti_download_dispatcher_task != GNUNET_SCHEDULER_NO_TASK) |
1614 | { | 1597 | { |
1615 | GNUNET_SCHEDULER_cancel (sched, | 1598 | GNUNET_SCHEDULER_cancel (ti_download_dispatcher_task); |
1616 | ti_download_dispatcher_task); | ||
1617 | } | 1599 | } |
1618 | if (ti_testing_intervall_task != GNUNET_SCHEDULER_NO_TASK) | 1600 | if (ti_testing_intervall_task != GNUNET_SCHEDULER_NO_TASK) |
1619 | { | 1601 | { |
1620 | GNUNET_SCHEDULER_cancel (sched, | 1602 | GNUNET_SCHEDULER_cancel (ti_testing_intervall_task); |
1621 | ti_testing_intervall_task); | ||
1622 | } | 1603 | } |
1623 | if (ti_download != GNUNET_SCHEDULER_NO_TASK) | 1604 | if (ti_download != GNUNET_SCHEDULER_NO_TASK) |
1624 | { | 1605 | { |
1625 | GNUNET_SCHEDULER_cancel (sched, | 1606 | GNUNET_SCHEDULER_cancel (ti_download); |
1626 | ti_download); | ||
1627 | } | 1607 | } |
1628 | if (ti_check_download != GNUNET_SCHEDULER_NO_TASK) | 1608 | if (ti_check_download != GNUNET_SCHEDULER_NO_TASK) |
1629 | { | 1609 | { |
1630 | GNUNET_SCHEDULER_cancel (sched, | 1610 | GNUNET_SCHEDULER_cancel (ti_check_download); |
1631 | ti_check_download); | ||
1632 | curl_global_cleanup (); | 1611 | curl_global_cleanup (); |
1633 | } | 1612 | } |
1634 | if (transport != NULL) | 1613 | if (transport != NULL) |
@@ -1640,7 +1619,6 @@ GNUNET_HOSTLIST_client_stop () | |||
1640 | GNUNET_free_non_null (proxy); | 1619 | GNUNET_free_non_null (proxy); |
1641 | proxy = NULL; | 1620 | proxy = NULL; |
1642 | cfg = NULL; | 1621 | cfg = NULL; |
1643 | sched = NULL; | ||
1644 | } | 1622 | } |
1645 | 1623 | ||
1646 | /* end of hostlist-client.c */ | 1624 | /* end of hostlist-client.c */ |