aboutsummaryrefslogtreecommitdiff
path: root/src/hostlist
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-04-09 23:14:03 +0000
committerChristian Grothoff <christian@grothoff.org>2016-04-09 23:14:03 +0000
commit29e6158507a0758192075ac6ece7ba8e75ddc49a (patch)
treeb91ded48da322f8ba4c9bb0f5504228aa036c2d1 /src/hostlist
parent5dfcb058ab5db9ae0c4b147d8a99c64ca0980028 (diff)
downloadgnunet-29e6158507a0758192075ac6ece7ba8e75ddc49a.tar.gz
gnunet-29e6158507a0758192075ac6ece7ba8e75ddc49a.zip
small API change: do no longer pass rarely needed GNUNET_SCHEDULER_TaskContext to all scheduler tasks; instead, allow the relatively few tasks that need it to obtain the context via GNUNET_SCHEDULER_get_task_context()
Diffstat (limited to 'src/hostlist')
-rw-r--r--src/hostlist/gnunet-daemon-hostlist.c4
-rw-r--r--src/hostlist/gnunet-daemon-hostlist_client.c32
-rw-r--r--src/hostlist/gnunet-daemon-hostlist_server.c7
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist.c10
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist_learning.c9
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist_reconnect.c10
6 files changed, 38 insertions, 34 deletions
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c
index 42b5959f2..6a4689af1 100644
--- a/src/hostlist/gnunet-daemon-hostlist.c
+++ b/src/hostlist/gnunet-daemon-hostlist.c
@@ -212,11 +212,9 @@ disconnect_handler (void *cls,
212 * the other services. 212 * the other services.
213 * 213 *
214 * @param cls NULL 214 * @param cls NULL
215 * @param tc scheduler context
216 */ 215 */
217static void 216static void
218cleaning_task (void *cls, 217cleaning_task (void *cls)
219 const struct GNUNET_SCHEDULER_TaskContext *tc)
220{ 218{
221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 219 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
222 "Hostlist daemon is shutting down\n"); 220 "Hostlist daemon is shutting down\n");
diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c b/src/hostlist/gnunet-daemon-hostlist_client.c
index e0a73f0f0..dbf6eaeda 100644
--- a/src/hostlist/gnunet-daemon-hostlist_client.c
+++ b/src/hostlist/gnunet-daemon-hostlist_client.c
@@ -774,8 +774,7 @@ clean_up ()
774 * @param tc task context, unused 774 * @param tc task context, unused
775 */ 775 */
776static void 776static void
777task_download (void *cls, 777task_download (void *cls);
778 const struct GNUNET_SCHEDULER_TaskContext *tc);
779 778
780 779
781/** 780/**
@@ -841,17 +840,17 @@ download_prepare ()
841 * server. 840 * server.
842 * 841 *
843 * @param cls closure, unused 842 * @param cls closure, unused
844 * @param tc task context, unused
845 */ 843 */
846static void 844static void
847task_download (void *cls, 845task_download (void *cls)
848 const struct GNUNET_SCHEDULER_TaskContext *tc)
849{ 846{
850 int running; 847 int running;
851 struct CURLMsg *msg; 848 struct CURLMsg *msg;
852 CURLMcode mret; 849 CURLMcode mret;
850 const struct GNUNET_SCHEDULER_TaskContext *tc;
853 851
854 ti_download = NULL; 852 ti_download = NULL;
853 tc = GNUNET_SCHEDULER_get_task_context ();
855 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 854 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
856 { 855 {
857 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 856 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1046,10 +1045,12 @@ download_hostlist ()
1046 1045
1047 1046
1048static void 1047static void
1049task_download_dispatcher (void *cls, 1048task_download_dispatcher (void *cls)
1050 const struct GNUNET_SCHEDULER_TaskContext *tc)
1051{ 1049{
1050 const struct GNUNET_SCHEDULER_TaskContext *tc;
1051
1052 ti_download_dispatcher_task = NULL; 1052 ti_download_dispatcher_task = NULL;
1053 tc = GNUNET_SCHEDULER_get_task_context ();
1053 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1054 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1054 return; 1055 return;
1055 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download is initiated...\n"); 1056 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download is initiated...\n");
@@ -1075,12 +1076,14 @@ task_download_dispatcher (void *cls,
1075 * this task again for a later time. 1076 * this task again for a later time.
1076 */ 1077 */
1077static void 1078static void
1078task_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1079task_check (void *cls)
1079{ 1080{
1080 static int once; 1081 static int once;
1081 struct GNUNET_TIME_Relative delay; 1082 struct GNUNET_TIME_Relative delay;
1083 const struct GNUNET_SCHEDULER_TaskContext *tc;
1082 1084
1083 ti_check_download = NULL; 1085 ti_check_download = NULL;
1086 tc = GNUNET_SCHEDULER_get_task_context ();
1084 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1087 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1085 return; 1088 return;
1086 if (stats == NULL) 1089 if (stats == NULL)
@@ -1125,13 +1128,14 @@ task_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1125 * This tasks sets hostlist testing to allowed after intervall between to testings is reached 1128 * This tasks sets hostlist testing to allowed after intervall between to testings is reached
1126 * 1129 *
1127 * @param cls closure 1130 * @param cls closure
1128 * @param tc TaskContext
1129 */ 1131 */
1130static void 1132static void
1131task_testing_intervall_reset (void *cls, 1133task_testing_intervall_reset (void *cls)
1132 const struct GNUNET_SCHEDULER_TaskContext *tc)
1133{ 1134{
1135 const struct GNUNET_SCHEDULER_TaskContext *tc;
1136
1134 ti_testing_intervall_task = NULL; 1137 ti_testing_intervall_task = NULL;
1138 tc = GNUNET_SCHEDULER_get_task_context ();
1135 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1139 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1136 return; 1140 return;
1137 stat_testing_allowed = GNUNET_OK; 1141 stat_testing_allowed = GNUNET_OK;
@@ -1144,12 +1148,14 @@ task_testing_intervall_reset (void *cls,
1144 * Task that writes hostlist entries to a file on a regular base 1148 * Task that writes hostlist entries to a file on a regular base
1145 * 1149 *
1146 * @param cls closure 1150 * @param cls closure
1147 * @param tc TaskContext
1148 */ 1151 */
1149static void 1152static void
1150task_hostlist_saving (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1153task_hostlist_saving (void *cls)
1151{ 1154{
1155 const struct GNUNET_SCHEDULER_TaskContext *tc;
1156
1152 ti_saving_task = NULL; 1157 ti_saving_task = NULL;
1158 tc = GNUNET_SCHEDULER_get_task_context ();
1153 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1159 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1154 return; 1160 return;
1155 save_hostlist_file (GNUNET_NO); 1161 save_hostlist_file (GNUNET_NO);
diff --git a/src/hostlist/gnunet-daemon-hostlist_server.c b/src/hostlist/gnunet-daemon-hostlist_server.c
index 7c5b18605..6e2cb7ee4 100644
--- a/src/hostlist/gnunet-daemon-hostlist_server.c
+++ b/src/hostlist/gnunet-daemon-hostlist_server.c
@@ -627,19 +627,18 @@ prepare_daemon (struct MHD_Daemon *daemon_handle);
627 * and schedule the next run. 627 * and schedule the next run.
628 * 628 *
629 * @param cls the `struct MHD_Daemon` of the HTTP server to run 629 * @param cls the `struct MHD_Daemon` of the HTTP server to run
630 * @param tc scheduler context
631 */ 630 */
632static void 631static void
633run_daemon (void *cls, 632run_daemon (void *cls)
634 const struct GNUNET_SCHEDULER_TaskContext *tc)
635{ 633{
636 struct MHD_Daemon *daemon_handle = cls; 634 struct MHD_Daemon *daemon_handle = cls;
635 const struct GNUNET_SCHEDULER_TaskContext *tc;
637 636
638 if (daemon_handle == daemon_handle_v4) 637 if (daemon_handle == daemon_handle_v4)
639 hostlist_task_v4 = NULL; 638 hostlist_task_v4 = NULL;
640 else 639 else
641 hostlist_task_v6 = NULL; 640 hostlist_task_v6 = NULL;
642 641 tc = GNUNET_SCHEDULER_get_task_context ();
643 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 642 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
644 return; 643 return;
645 GNUNET_assert (MHD_YES == MHD_run (daemon_handle)); 644 GNUNET_assert (MHD_YES == MHD_run (daemon_handle));
diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c
index 05e05e24e..2f99b887d 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist.c
@@ -52,7 +52,7 @@ static struct PeerContext p2;
52 52
53 53
54static void 54static void
55clean_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 55clean_up (void *cls)
56{ 56{
57 if (p1.th != NULL) 57 if (p1.th != NULL)
58 { 58 {
@@ -81,12 +81,12 @@ clean_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
81 * Timeout, give up. 81 * Timeout, give up.
82 */ 82 */
83static void 83static void
84timeout_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 84timeout_error (void *cls)
85{ 85{
86 timeout_task = NULL; 86 timeout_task = NULL;
87 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 87 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
88 "Timeout trying to connect peers, test failed.\n"); 88 "Timeout trying to connect peers, test failed.\n");
89 clean_up (NULL, tc); 89 clean_up (NULL);
90} 90}
91 91
92 92
@@ -150,7 +150,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
150 150
151 151
152static void 152static void
153waitpid_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 153waitpid_task (void *cls)
154{ 154{
155 struct PeerContext *p = cls; 155 struct PeerContext *p = cls;
156 156
@@ -179,7 +179,7 @@ stop_arm (struct PeerContext *p)
179 * Try again to connect to transport service. 179 * Try again to connect to transport service.
180 */ 180 */
181static void 181static void
182shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 182shutdown_task (void *cls)
183{ 183{
184 stop_arm (&p1); 184 stop_arm (&p1);
185 stop_arm (&p2); 185 stop_arm (&p2);
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c
index d04c5c57f..a71b8ecae 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c
@@ -166,7 +166,7 @@ shutdown_testcase ()
166 * Timeout, give up. 166 * Timeout, give up.
167 */ 167 */
168static void 168static void
169timeout_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 169timeout_error (void *cls)
170{ 170{
171 timeout_task = NULL; 171 timeout_task = NULL;
172 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 172 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -184,8 +184,7 @@ process_downloads_done (void *cls, int success)
184 184
185 185
186static void 186static void
187do_shutdown (void *cls, 187do_shutdown (void *cls)
188 const struct GNUNET_SCHEDULER_TaskContext *tc)
189{ 188{
190 shutdown_testcase (); 189 shutdown_testcase ();
191} 190}
@@ -265,11 +264,13 @@ process_adv_sent (void *cls, const char *subsystem, const char *name,
265 * Check the server statistics regularly 264 * Check the server statistics regularly
266 */ 265 */
267static void 266static void
268check_statistics (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 267check_statistics (void *cls)
269{ 268{
270 char *stat; 269 char *stat;
270 const struct GNUNET_SCHEDULER_TaskContext *tc;
271 271
272 check_task = NULL; 272 check_task = NULL;
273 tc = GNUNET_SCHEDULER_get_task_context ();
273 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 274 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
274 return; 275 return;
275 GNUNET_asprintf (&stat, gettext_noop ("# advertised URI `%s' downloaded"), 276 GNUNET_asprintf (&stat, gettext_noop ("# advertised URI `%s' downloaded"),
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
index e7ac9b2bc..0af16e065 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
@@ -52,7 +52,7 @@ static struct PeerContext p2;
52 52
53 53
54static void 54static void
55clean_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 55clean_up (void *cls)
56{ 56{
57 if (NULL != p1.ghh) 57 if (NULL != p1.ghh)
58 { 58 {
@@ -81,12 +81,12 @@ clean_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
81 * Timeout, give up. 81 * Timeout, give up.
82 */ 82 */
83static void 83static void
84timeout_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 84timeout_error (void *cls)
85{ 85{
86 timeout_task = NULL; 86 timeout_task = NULL;
87 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 87 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
88 "Timeout trying to connect peers, test failed.\n"); 88 "Timeout trying to connect peers, test failed.\n");
89 clean_up (NULL, tc); 89 clean_up (NULL);
90} 90}
91 91
92 92
@@ -150,7 +150,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
150 150
151 151
152static void 152static void
153waitpid_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 153waitpid_task (void *cls)
154{ 154{
155 struct PeerContext *p = cls; 155 struct PeerContext *p = cls;
156 156
@@ -179,7 +179,7 @@ stop_arm (struct PeerContext *p)
179 * Try again to connect to transport service. 179 * Try again to connect to transport service.
180 */ 180 */
181static void 181static void
182shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 182shutdown_task (void *cls)
183{ 183{
184 stop_arm (&p1); 184 stop_arm (&p1);
185 stop_arm (&p2); 185 stop_arm (&p2);