diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-04-30 08:17:37 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-04-30 08:17:37 +0000 |
commit | 95f9076a2139f5fb042b944a0658b6cda2fa35db (patch) | |
tree | b0826a2a1dcf812e6b4450fe6b05d47cd53ae49d /src/hostlist | |
parent | 7746f68db77b9ca3c4aaca24ab2ce5253461240b (diff) | |
download | gnunet-95f9076a2139f5fb042b944a0658b6cda2fa35db.tar.gz gnunet-95f9076a2139f5fb042b944a0658b6cda2fa35db.zip |
implementing new scheduler shutdown semantics
Diffstat (limited to 'src/hostlist')
-rw-r--r-- | src/hostlist/gnunet-daemon-hostlist.c | 5 | ||||
-rw-r--r-- | src/hostlist/gnunet-daemon-hostlist_client.c | 71 | ||||
-rw-r--r-- | src/hostlist/gnunet-daemon-hostlist_server.c | 19 | ||||
-rw-r--r-- | src/hostlist/test_gnunet_daemon_hostlist.c | 29 | ||||
-rw-r--r-- | src/hostlist/test_gnunet_daemon_hostlist_learning.c | 14 | ||||
-rw-r--r-- | src/hostlist/test_gnunet_daemon_hostlist_reconnect.c | 18 |
6 files changed, 71 insertions, 85 deletions
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c index 6a4689af1..21fab323b 100644 --- a/src/hostlist/gnunet-daemon-hostlist.c +++ b/src/hostlist/gnunet-daemon-hostlist.c | |||
@@ -299,9 +299,8 @@ run (void *cls, | |||
299 | GNUNET_HOSTLIST_server_start (cfg, stats, core, &server_ch, &server_dh, | 299 | GNUNET_HOSTLIST_server_start (cfg, stats, core, &server_ch, &server_dh, |
300 | advertising); | 300 | advertising); |
301 | #endif | 301 | #endif |
302 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 302 | GNUNET_SCHEDULER_add_shutdown (&cleaning_task, |
303 | &cleaning_task, | 303 | NULL); |
304 | NULL); | ||
305 | 304 | ||
306 | if (NULL == core) | 305 | if (NULL == core) |
307 | { | 306 | { |
diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c b/src/hostlist/gnunet-daemon-hostlist_client.c index dbf6eaeda..15a82c2d5 100644 --- a/src/hostlist/gnunet-daemon-hostlist_client.c +++ b/src/hostlist/gnunet-daemon-hostlist_client.c | |||
@@ -210,27 +210,27 @@ static struct GNUNET_TIME_Relative hostlist_delay; | |||
210 | /** | 210 | /** |
211 | * ID of the task, checking if hostlist download should take plate | 211 | * ID of the task, checking if hostlist download should take plate |
212 | */ | 212 | */ |
213 | static struct GNUNET_SCHEDULER_Task * ti_check_download; | 213 | static struct GNUNET_SCHEDULER_Task *ti_check_download; |
214 | 214 | ||
215 | /** | 215 | /** |
216 | * ID of the task downloading the hostlist | 216 | * ID of the task downloading the hostlist |
217 | */ | 217 | */ |
218 | static struct GNUNET_SCHEDULER_Task * ti_download; | 218 | static struct GNUNET_SCHEDULER_Task *ti_download; |
219 | 219 | ||
220 | /** | 220 | /** |
221 | * ID of the task saving the hostlsit in a regular intervall | 221 | * ID of the task saving the hostlsit in a regular intervall |
222 | */ | 222 | */ |
223 | static struct GNUNET_SCHEDULER_Task * ti_saving_task; | 223 | static struct GNUNET_SCHEDULER_Task *ti_saving_task; |
224 | 224 | ||
225 | /** | 225 | /** |
226 | * ID of the task called to initiate a download | 226 | * ID of the task called to initiate a download |
227 | */ | 227 | */ |
228 | static struct GNUNET_SCHEDULER_Task * ti_download_dispatcher_task; | 228 | static struct GNUNET_SCHEDULER_Task *ti_download_dispatcher_task; |
229 | 229 | ||
230 | /** | 230 | /** |
231 | * ID of the task controlling the locking between two hostlist tests | 231 | * ID of the task controlling the locking between two hostlist tests |
232 | */ | 232 | */ |
233 | static struct GNUNET_SCHEDULER_Task * ti_testing_intervall_task; | 233 | static struct GNUNET_SCHEDULER_Task *ti_testing_intervall_task; |
234 | 234 | ||
235 | /** | 235 | /** |
236 | * At what time MUST the current hostlist request be done? | 236 | * At what time MUST the current hostlist request be done? |
@@ -719,8 +719,9 @@ clean_up () | |||
719 | { | 719 | { |
720 | CURLMcode mret; | 720 | CURLMcode mret; |
721 | 721 | ||
722 | if ((stat_testing_hostlist == GNUNET_YES) && | 722 | if ( (stat_testing_hostlist == GNUNET_YES) && |
723 | (GNUNET_NO == stat_download_successful) && (NULL != hostlist_to_test)) | 723 | (GNUNET_NO == stat_download_successful) && |
724 | (NULL != hostlist_to_test) ) | ||
724 | { | 725 | { |
725 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 726 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
726 | _ | 727 | _ |
@@ -738,7 +739,7 @@ clean_up () | |||
738 | hostlist_to_test = NULL; | 739 | hostlist_to_test = NULL; |
739 | } | 740 | } |
740 | 741 | ||
741 | if (multi != NULL) | 742 | if (NULL != multi) |
742 | { | 743 | { |
743 | mret = curl_multi_remove_handle (multi, curl); | 744 | mret = curl_multi_remove_handle (multi, curl); |
744 | if (mret != CURLM_OK) | 745 | if (mret != CURLM_OK) |
@@ -754,7 +755,7 @@ clean_up () | |||
754 | curl_multi_strerror (mret)); | 755 | curl_multi_strerror (mret)); |
755 | multi = NULL; | 756 | multi = NULL; |
756 | } | 757 | } |
757 | if (curl != NULL) | 758 | if (NULL != curl) |
758 | { | 759 | { |
759 | curl_easy_cleanup (curl); | 760 | curl_easy_cleanup (curl); |
760 | curl = NULL; | 761 | curl = NULL; |
@@ -847,19 +848,8 @@ task_download (void *cls) | |||
847 | int running; | 848 | int running; |
848 | struct CURLMsg *msg; | 849 | struct CURLMsg *msg; |
849 | CURLMcode mret; | 850 | CURLMcode mret; |
850 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
851 | 851 | ||
852 | ti_download = NULL; | 852 | ti_download = NULL; |
853 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
854 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
855 | { | ||
856 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
857 | "Shutdown requested while trying to download hostlist from `%s'\n", | ||
858 | current_url); | ||
859 | update_hostlist (); | ||
860 | clean_up (); | ||
861 | return; | ||
862 | } | ||
863 | if (0 == GNUNET_TIME_absolute_get_remaining (end_time).rel_value_us) | 853 | if (0 == GNUNET_TIME_absolute_get_remaining (end_time).rel_value_us) |
864 | { | 854 | { |
865 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 855 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -1047,12 +1037,7 @@ download_hostlist () | |||
1047 | static void | 1037 | static void |
1048 | task_download_dispatcher (void *cls) | 1038 | task_download_dispatcher (void *cls) |
1049 | { | 1039 | { |
1050 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1051 | |||
1052 | ti_download_dispatcher_task = NULL; | 1040 | ti_download_dispatcher_task = NULL; |
1053 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1054 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1055 | return; | ||
1056 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download is initiated...\n"); | 1041 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download is initiated...\n"); |
1057 | if (GNUNET_NO == stat_download_in_progress) | 1042 | if (GNUNET_NO == stat_download_in_progress) |
1058 | { | 1043 | { |
@@ -1080,12 +1065,8 @@ task_check (void *cls) | |||
1080 | { | 1065 | { |
1081 | static int once; | 1066 | static int once; |
1082 | struct GNUNET_TIME_Relative delay; | 1067 | struct GNUNET_TIME_Relative delay; |
1083 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1084 | 1068 | ||
1085 | ti_check_download = NULL; | 1069 | ti_check_download = NULL; |
1086 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1087 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1088 | return; | ||
1089 | if (stats == NULL) | 1070 | if (stats == NULL) |
1090 | { | 1071 | { |
1091 | curl_global_cleanup (); | 1072 | curl_global_cleanup (); |
@@ -1120,7 +1101,8 @@ task_check (void *cls) | |||
1120 | _("Have %u/%u connections. Will consider downloading hostlist in %s\n"), | 1101 | _("Have %u/%u connections. Will consider downloading hostlist in %s\n"), |
1121 | stat_connection_count, MIN_CONNECTIONS, | 1102 | stat_connection_count, MIN_CONNECTIONS, |
1122 | GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); | 1103 | GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); |
1123 | ti_check_download = GNUNET_SCHEDULER_add_delayed (delay, &task_check, NULL); | 1104 | ti_check_download = GNUNET_SCHEDULER_add_delayed (delay, |
1105 | &task_check, NULL); | ||
1124 | } | 1106 | } |
1125 | 1107 | ||
1126 | 1108 | ||
@@ -1132,12 +1114,7 @@ task_check (void *cls) | |||
1132 | static void | 1114 | static void |
1133 | task_testing_intervall_reset (void *cls) | 1115 | task_testing_intervall_reset (void *cls) |
1134 | { | 1116 | { |
1135 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1136 | |||
1137 | ti_testing_intervall_task = NULL; | 1117 | ti_testing_intervall_task = NULL; |
1138 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1139 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1140 | return; | ||
1141 | stat_testing_allowed = GNUNET_OK; | 1118 | stat_testing_allowed = GNUNET_OK; |
1142 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1119 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1143 | "Testing new hostlist advertisements is allowed again\n"); | 1120 | "Testing new hostlist advertisements is allowed again\n"); |
@@ -1152,19 +1129,15 @@ task_testing_intervall_reset (void *cls) | |||
1152 | static void | 1129 | static void |
1153 | task_hostlist_saving (void *cls) | 1130 | task_hostlist_saving (void *cls) |
1154 | { | 1131 | { |
1155 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1156 | |||
1157 | ti_saving_task = NULL; | 1132 | ti_saving_task = NULL; |
1158 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1159 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1160 | return; | ||
1161 | save_hostlist_file (GNUNET_NO); | 1133 | save_hostlist_file (GNUNET_NO); |
1162 | 1134 | ||
1163 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1135 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1164 | "Hostlists will be saved to file again in %s\n", | 1136 | "Hostlists will be saved to file again in %s\n", |
1165 | GNUNET_STRINGS_relative_time_to_string(SAVING_INTERVAL, GNUNET_YES)); | 1137 | GNUNET_STRINGS_relative_time_to_string(SAVING_INTERVAL, GNUNET_YES)); |
1166 | ti_saving_task = | 1138 | ti_saving_task = |
1167 | GNUNET_SCHEDULER_add_delayed (SAVING_INTERVAL, &task_hostlist_saving, | 1139 | GNUNET_SCHEDULER_add_delayed (SAVING_INTERVAL, |
1140 | &task_hostlist_saving, | ||
1168 | NULL); | 1141 | NULL); |
1169 | } | 1142 | } |
1170 | 1143 | ||
@@ -1684,7 +1657,8 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1684 | void | 1657 | void |
1685 | GNUNET_HOSTLIST_client_stop () | 1658 | GNUNET_HOSTLIST_client_stop () |
1686 | { | 1659 | { |
1687 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hostlist client shutdown\n"); | 1660 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1661 | "Hostlist client shutdown\n"); | ||
1688 | if (NULL != sget) | 1662 | if (NULL != sget) |
1689 | { | 1663 | { |
1690 | GNUNET_STATISTICS_get_cancel (sget); | 1664 | GNUNET_STATISTICS_get_cancel (sget); |
@@ -1693,28 +1667,29 @@ GNUNET_HOSTLIST_client_stop () | |||
1693 | stats = NULL; | 1667 | stats = NULL; |
1694 | if (GNUNET_YES == stat_learning) | 1668 | if (GNUNET_YES == stat_learning) |
1695 | save_hostlist_file (GNUNET_YES); | 1669 | save_hostlist_file (GNUNET_YES); |
1696 | if (ti_saving_task != NULL) | 1670 | if (NULL != ti_saving_task) |
1697 | { | 1671 | { |
1698 | GNUNET_SCHEDULER_cancel (ti_saving_task); | 1672 | GNUNET_SCHEDULER_cancel (ti_saving_task); |
1699 | ti_saving_task = NULL; | 1673 | ti_saving_task = NULL; |
1700 | } | 1674 | } |
1701 | 1675 | if (NULL != ti_download_dispatcher_task) | |
1702 | if (ti_download_dispatcher_task != NULL) | ||
1703 | { | 1676 | { |
1704 | GNUNET_SCHEDULER_cancel (ti_download_dispatcher_task); | 1677 | GNUNET_SCHEDULER_cancel (ti_download_dispatcher_task); |
1705 | ti_download_dispatcher_task = NULL; | 1678 | ti_download_dispatcher_task = NULL; |
1706 | } | 1679 | } |
1707 | if (ti_testing_intervall_task != NULL) | 1680 | if (NULL != ti_testing_intervall_task) |
1708 | { | 1681 | { |
1709 | GNUNET_SCHEDULER_cancel (ti_testing_intervall_task); | 1682 | GNUNET_SCHEDULER_cancel (ti_testing_intervall_task); |
1710 | ti_testing_intervall_task = NULL; | 1683 | ti_testing_intervall_task = NULL; |
1711 | } | 1684 | } |
1712 | if (ti_download != NULL) | 1685 | if (NULL != ti_download) |
1713 | { | 1686 | { |
1714 | GNUNET_SCHEDULER_cancel (ti_download); | 1687 | GNUNET_SCHEDULER_cancel (ti_download); |
1715 | ti_download = NULL; | 1688 | ti_download = NULL; |
1689 | update_hostlist (); | ||
1690 | clean_up (); | ||
1716 | } | 1691 | } |
1717 | if (ti_check_download != NULL) | 1692 | if (NULL != ti_check_download) |
1718 | { | 1693 | { |
1719 | GNUNET_SCHEDULER_cancel (ti_check_download); | 1694 | GNUNET_SCHEDULER_cancel (ti_check_download); |
1720 | ti_check_download = NULL; | 1695 | ti_check_download = NULL; |
diff --git a/src/hostlist/gnunet-daemon-hostlist_server.c b/src/hostlist/gnunet-daemon-hostlist_server.c index 6e2cb7ee4..5b45af831 100644 --- a/src/hostlist/gnunet-daemon-hostlist_server.c +++ b/src/hostlist/gnunet-daemon-hostlist_server.c | |||
@@ -74,12 +74,12 @@ static struct GNUNET_PEERINFO_NotifyContext *notify; | |||
74 | /** | 74 | /** |
75 | * Our primary task for IPv4. | 75 | * Our primary task for IPv4. |
76 | */ | 76 | */ |
77 | static struct GNUNET_SCHEDULER_Task * hostlist_task_v4; | 77 | static struct GNUNET_SCHEDULER_Task *hostlist_task_v4; |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Our primary task for IPv6. | 80 | * Our primary task for IPv6. |
81 | */ | 81 | */ |
82 | static struct GNUNET_SCHEDULER_Task * hostlist_task_v6; | 82 | static struct GNUNET_SCHEDULER_Task *hostlist_task_v6; |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * Our canonical response. | 85 | * Our canonical response. |
@@ -632,15 +632,11 @@ static void | |||
632 | run_daemon (void *cls) | 632 | run_daemon (void *cls) |
633 | { | 633 | { |
634 | struct MHD_Daemon *daemon_handle = cls; | 634 | struct MHD_Daemon *daemon_handle = cls; |
635 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
636 | 635 | ||
637 | if (daemon_handle == daemon_handle_v4) | 636 | if (daemon_handle == daemon_handle_v4) |
638 | hostlist_task_v4 = NULL; | 637 | hostlist_task_v4 = NULL; |
639 | else | 638 | else |
640 | hostlist_task_v6 = NULL; | 639 | hostlist_task_v6 = NULL; |
641 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
642 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
643 | return; | ||
644 | GNUNET_assert (MHD_YES == MHD_run (daemon_handle)); | 640 | GNUNET_assert (MHD_YES == MHD_run (daemon_handle)); |
645 | if (daemon_handle == daemon_handle_v4) | 641 | if (daemon_handle == daemon_handle_v4) |
646 | hostlist_task_v4 = prepare_daemon (daemon_handle); | 642 | hostlist_task_v4 = prepare_daemon (daemon_handle); |
@@ -675,7 +671,9 @@ prepare_daemon (struct MHD_Daemon *daemon_handle) | |||
675 | wrs = GNUNET_NETWORK_fdset_create (); | 671 | wrs = GNUNET_NETWORK_fdset_create (); |
676 | wws = GNUNET_NETWORK_fdset_create (); | 672 | wws = GNUNET_NETWORK_fdset_create (); |
677 | max = -1; | 673 | max = -1; |
678 | GNUNET_assert (MHD_YES == MHD_get_fdset (daemon_handle, &rs, &ws, &es, &max)); | 674 | GNUNET_assert (MHD_YES == |
675 | MHD_get_fdset (daemon_handle, | ||
676 | &rs, &ws, &es, &max)); | ||
679 | haveto = MHD_get_timeout (daemon_handle, &timeout); | 677 | haveto = MHD_get_timeout (daemon_handle, &timeout); |
680 | if (haveto == MHD_YES) | 678 | if (haveto == MHD_YES) |
681 | tv.rel_value_us = (uint64_t) timeout * 1000LL; | 679 | tv.rel_value_us = (uint64_t) timeout * 1000LL; |
@@ -683,10 +681,9 @@ prepare_daemon (struct MHD_Daemon *daemon_handle) | |||
683 | tv = GNUNET_TIME_UNIT_FOREVER_REL; | 681 | tv = GNUNET_TIME_UNIT_FOREVER_REL; |
684 | GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1); | 682 | GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1); |
685 | GNUNET_NETWORK_fdset_copy_native (wws, &ws, max + 1); | 683 | GNUNET_NETWORK_fdset_copy_native (wws, &ws, max + 1); |
686 | ret = | 684 | ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, |
687 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, | 685 | tv, wrs, wws, |
688 | tv, wrs, wws, | 686 | &run_daemon, daemon_handle); |
689 | &run_daemon, daemon_handle); | ||
690 | GNUNET_NETWORK_fdset_destroy (wrs); | 687 | GNUNET_NETWORK_fdset_destroy (wrs); |
691 | GNUNET_NETWORK_fdset_destroy (wws); | 688 | GNUNET_NETWORK_fdset_destroy (wws); |
692 | return ret; | 689 | return ret; |
diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c index 2f99b887d..5f8ece9b8 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist.c +++ b/src/hostlist/test_gnunet_daemon_hostlist.c | |||
@@ -35,7 +35,7 @@ | |||
35 | 35 | ||
36 | static int ok; | 36 | static int ok; |
37 | 37 | ||
38 | static struct GNUNET_SCHEDULER_Task * timeout_task; | 38 | static struct GNUNET_SCHEDULER_Task *timeout_task; |
39 | 39 | ||
40 | struct PeerContext | 40 | struct PeerContext |
41 | { | 41 | { |
@@ -100,11 +100,13 @@ timeout_error (void *cls) | |||
100 | * @param distance in overlay hops, as given by transport plugin | 100 | * @param distance in overlay hops, as given by transport plugin |
101 | */ | 101 | */ |
102 | static void | 102 | static void |
103 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | 103 | notify_connect (void *cls, |
104 | const struct GNUNET_PeerIdentity *peer) | ||
104 | { | 105 | { |
105 | if (peer == NULL) | 106 | if (peer == NULL) |
106 | return; | 107 | return; |
107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected, shutting down.\n"); | 108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
109 | "Peers connected, shutting down.\n"); | ||
108 | ok = 0; | 110 | ok = 0; |
109 | if (timeout_task != NULL) | 111 | if (timeout_task != NULL) |
110 | { | 112 | { |
@@ -116,7 +118,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
116 | 118 | ||
117 | 119 | ||
118 | static void | 120 | static void |
119 | process_hello (void *cls, const struct GNUNET_MessageHeader *message) | 121 | process_hello (void *cls, |
122 | const struct GNUNET_MessageHeader *message) | ||
120 | { | 123 | { |
121 | struct PeerContext *p = cls; | 124 | struct PeerContext *p = cls; |
122 | 125 | ||
@@ -170,8 +173,10 @@ waitpid_task (void *cls) | |||
170 | static void | 173 | static void |
171 | stop_arm (struct PeerContext *p) | 174 | stop_arm (struct PeerContext *p) |
172 | { | 175 | { |
173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking ARM to stop core service\n"); | 176 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
174 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &waitpid_task, p); | 177 | "Asking ARM to stop core service\n"); |
178 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
179 | &waitpid_task, p); | ||
175 | } | 180 | } |
176 | 181 | ||
177 | 182 | ||
@@ -187,14 +192,18 @@ shutdown_task (void *cls) | |||
187 | 192 | ||
188 | 193 | ||
189 | static void | 194 | static void |
190 | run (void *cls, char *const *args, const char *cfgfile, | 195 | run (void *cls, |
196 | char *const *args, | ||
197 | const char *cfgfile, | ||
191 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 198 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
192 | { | 199 | { |
193 | GNUNET_assert (ok == 1); | 200 | GNUNET_assert (ok == 1); |
194 | ok++; | 201 | ok++; |
195 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_error, NULL); | 202 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
196 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 203 | &timeout_error, |
197 | NULL); | 204 | NULL); |
205 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | ||
206 | NULL); | ||
198 | setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf"); | 207 | setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf"); |
199 | setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf"); | 208 | setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf"); |
200 | } | 209 | } |
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c index a71b8ecae..717311be7 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c | |||
@@ -242,7 +242,9 @@ process_adv_sent_done (void *cls, int success) | |||
242 | 242 | ||
243 | 243 | ||
244 | static int | 244 | static int |
245 | process_adv_sent (void *cls, const char *subsystem, const char *name, | 245 | process_adv_sent (void *cls, |
246 | const char *subsystem, | ||
247 | const char *name, | ||
246 | uint64_t value, int is_persistent) | 248 | uint64_t value, int is_persistent) |
247 | { | 249 | { |
248 | if ((value >= 1) && (adv_sent == GNUNET_NO)) | 250 | if ((value >= 1) && (adv_sent == GNUNET_NO)) |
@@ -267,13 +269,10 @@ static void | |||
267 | check_statistics (void *cls) | 269 | check_statistics (void *cls) |
268 | { | 270 | { |
269 | char *stat; | 271 | char *stat; |
270 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
271 | 272 | ||
272 | check_task = NULL; | 273 | check_task = NULL; |
273 | tc = GNUNET_SCHEDULER_get_task_context (); | 274 | GNUNET_asprintf (&stat, |
274 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 275 | gettext_noop ("# advertised URI `%s' downloaded"), |
275 | return; | ||
276 | GNUNET_asprintf (&stat, gettext_noop ("# advertised URI `%s' downloaded"), | ||
277 | current_adv_uri); | 276 | current_adv_uri); |
278 | if (NULL != learn_peer.stats) | 277 | if (NULL != learn_peer.stats) |
279 | { | 278 | { |
@@ -313,7 +312,8 @@ check_statistics (void *cls) | |||
313 | * Core handler for p2p hostlist advertisements | 312 | * Core handler for p2p hostlist advertisements |
314 | */ | 313 | */ |
315 | static int | 314 | static int |
316 | ad_arrive_handler (void *cls, const struct GNUNET_PeerIdentity *peer, | 315 | ad_arrive_handler (void *cls, |
316 | const struct GNUNET_PeerIdentity *peer, | ||
317 | const struct GNUNET_MessageHeader *message) | 317 | const struct GNUNET_MessageHeader *message) |
318 | { | 318 | { |
319 | char *hostname; | 319 | char *hostname; |
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c index 0af16e065..562eec55b 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c | |||
@@ -100,11 +100,13 @@ timeout_error (void *cls) | |||
100 | * @param distance in overlay hops, as given by transport plugin | 100 | * @param distance in overlay hops, as given by transport plugin |
101 | */ | 101 | */ |
102 | static void | 102 | static void |
103 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | 103 | notify_connect (void *cls, |
104 | const struct GNUNET_PeerIdentity *peer) | ||
104 | { | 105 | { |
105 | if (peer == NULL) | 106 | if (peer == NULL) |
106 | return; | 107 | return; |
107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected, shutting down.\n"); | 108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
109 | "Peers connected, shutting down.\n"); | ||
108 | ok = 0; | 110 | ok = 0; |
109 | if (timeout_task != NULL) | 111 | if (timeout_task != NULL) |
110 | { | 112 | { |
@@ -116,7 +118,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
116 | 118 | ||
117 | 119 | ||
118 | static void | 120 | static void |
119 | process_hello (void *cls, const struct GNUNET_MessageHeader *message) | 121 | process_hello (void *cls, |
122 | const struct GNUNET_MessageHeader *message) | ||
120 | { | 123 | { |
121 | struct PeerContext *p = cls; | 124 | struct PeerContext *p = cls; |
122 | 125 | ||
@@ -171,7 +174,8 @@ static void | |||
171 | stop_arm (struct PeerContext *p) | 174 | stop_arm (struct PeerContext *p) |
172 | { | 175 | { |
173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking ARM to stop core service\n"); | 176 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking ARM to stop core service\n"); |
174 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &waitpid_task, p); | 177 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
178 | &waitpid_task, p); | ||
175 | } | 179 | } |
176 | 180 | ||
177 | 181 | ||
@@ -192,8 +196,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
192 | { | 196 | { |
193 | GNUNET_assert (ok == 1); | 197 | GNUNET_assert (ok == 1); |
194 | ok++; | 198 | ok++; |
195 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_error, NULL); | 199 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
196 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 200 | &timeout_error, NULL); |
201 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | ||
202 | &shutdown_task, | ||
197 | NULL); | 203 | NULL); |
198 | setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf"); | 204 | setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf"); |
199 | setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf"); | 205 | setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf"); |