aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/bandwidth.c4
-rw-r--r--src/util/client.c19
-rw-r--r--src/util/client_manager.c6
-rw-r--r--src/util/connection.c34
-rw-r--r--src/util/crypto_hash_file.c3
-rw-r--r--src/util/disk_iterator.c3
-rw-r--r--src/util/gnunet-scrypt.c5
-rw-r--r--src/util/gnunet-uri.c3
-rw-r--r--src/util/helper.c24
-rw-r--r--src/util/mq.c6
-rw-r--r--src/util/os_priority.c21
-rw-r--r--src/util/program.c4
-rw-r--r--src/util/resolver_api.c26
-rw-r--r--src/util/scheduler.c21
-rw-r--r--src/util/server.c26
-rw-r--r--src/util/service.c9
-rw-r--r--src/util/socks.c53
-rw-r--r--src/util/speedup.c7
-rw-r--r--src/util/test_client.c2
-rw-r--r--src/util/test_common_logging_runtime_loglevels.c6
-rw-r--r--src/util/test_connection.c4
-rw-r--r--src/util/test_connection_addressing.c4
-rw-r--r--src/util/test_connection_receive_cancel.c6
-rw-r--r--src/util/test_connection_timeout.c2
-rw-r--r--src/util/test_connection_timeout_no_connect.c2
-rw-r--r--src/util/test_connection_transmit_cancel.c2
-rw-r--r--src/util/test_crypto_hash.c2
-rw-r--r--src/util/test_disk.c3
-rw-r--r--src/util/test_mq_client.c5
-rw-r--r--src/util/test_os_start_process.c6
-rw-r--r--src/util/test_scheduler.c26
-rw-r--r--src/util/test_scheduler_delay.c4
-rw-r--r--src/util/test_server.c8
-rw-r--r--src/util/test_server_disconnect.c11
-rw-r--r--src/util/test_server_with_client.c6
-rw-r--r--src/util/test_server_with_client_unix.c6
-rw-r--r--src/util/test_service.c2
-rw-r--r--src/util/test_socks.c2
-rw-r--r--src/util/test_speedup.c2
39 files changed, 181 insertions, 204 deletions
diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c
index 5fbb608e7..2df2a9449 100644
--- a/src/util/bandwidth.c
+++ b/src/util/bandwidth.c
@@ -142,11 +142,9 @@ GNUNET_BANDWIDTH_value_get_delay_for (struct GNUNET_BANDWIDTH_Value32NBO bps,
142 * Task run whenever we hit the bandwidth limit for a tracker. 142 * Task run whenever we hit the bandwidth limit for a tracker.
143 * 143 *
144 * @param cls the `struct GNUNET_BANDWIDTH_Tracker` 144 * @param cls the `struct GNUNET_BANDWIDTH_Tracker`
145 * @param tc scheduler context
146 */ 145 */
147static void 146static void
148excess_trigger (void *cls, 147excess_trigger (void *cls)
149 const struct GNUNET_SCHEDULER_TaskContext *tc)
150{ 148{
151 struct GNUNET_BANDWIDTH_Tracker *av = cls; 149 struct GNUNET_BANDWIDTH_Tracker *av = cls;
152 150
diff --git a/src/util/client.c b/src/util/client.c
index d87be74f6..f93fd1d10 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -579,11 +579,9 @@ receive_helper (void *cls,
579 * Continuation to call the receive callback. 579 * Continuation to call the receive callback.
580 * 580 *
581 * @param cls our handle to the client connection 581 * @param cls our handle to the client connection
582 * @param tc scheduler context
583 */ 582 */
584static void 583static void
585receive_task (void *cls, 584receive_task (void *cls)
586 const struct GNUNET_SCHEDULER_TaskContext *tc)
587{ 585{
588 struct GNUNET_CLIENT_Connection *client = cls; 586 struct GNUNET_CLIENT_Connection *client = cls;
589 GNUNET_CLIENT_MessageHandler handler = client->receiver_handler; 587 GNUNET_CLIENT_MessageHandler handler = client->receiver_handler;
@@ -746,11 +744,9 @@ GNUNET_CLIENT_service_test_cancel (struct GNUNET_CLIENT_TestHandle *th)
746 * and then cleans up. 744 * and then cleans up.
747 * 745 *
748 * @param cls the `struct GNUNET_CLIENT_TestHandle` 746 * @param cls the `struct GNUNET_CLIENT_TestHandle`
749 * @param tc scheduler context
750 */ 747 */
751static void 748static void
752report_result (void *cls, 749report_result (void *cls)
753 const struct GNUNET_SCHEDULER_TaskContext *tc)
754{ 750{
755 struct GNUNET_CLIENT_TestHandle *th = cls; 751 struct GNUNET_CLIENT_TestHandle *th = cls;
756 752
@@ -1080,16 +1076,16 @@ client_notify (void *cls, size_t size, void *buf);
1080 * service after a while. 1076 * service after a while.
1081 * 1077 *
1082 * @param cls our `struct GNUNET_CLIENT_TransmitHandle` of the request 1078 * @param cls our `struct GNUNET_CLIENT_TransmitHandle` of the request
1083 * @param tc unused
1084 */ 1079 */
1085static void 1080static void
1086client_delayed_retry (void *cls, 1081client_delayed_retry (void *cls)
1087 const struct GNUNET_SCHEDULER_TaskContext *tc)
1088{ 1082{
1089 struct GNUNET_CLIENT_TransmitHandle *th = cls; 1083 struct GNUNET_CLIENT_TransmitHandle *th = cls;
1084 const struct GNUNET_SCHEDULER_TaskContext *tc;
1090 struct GNUNET_TIME_Relative delay; 1085 struct GNUNET_TIME_Relative delay;
1091 1086
1092 th->reconnect_task = NULL; 1087 th->reconnect_task = NULL;
1088 tc = GNUNET_SCHEDULER_get_task_context ();
1093 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1089 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1094 { 1090 {
1095 /* give up, was shutdown */ 1091 /* give up, was shutdown */
@@ -1153,11 +1149,14 @@ client_notify (void *cls,
1153 struct GNUNET_CLIENT_Connection *client = th->client; 1149 struct GNUNET_CLIENT_Connection *client = th->client;
1154 size_t ret; 1150 size_t ret;
1155 struct GNUNET_TIME_Relative delay; 1151 struct GNUNET_TIME_Relative delay;
1152 const struct GNUNET_SCHEDULER_TaskContext *tc;
1153
1156 1154
1157 LOG (GNUNET_ERROR_TYPE_DEBUG, 1155 LOG (GNUNET_ERROR_TYPE_DEBUG,
1158 "client_notify is running\n"); 1156 "client_notify is running\n");
1159 th->th = NULL; 1157 th->th = NULL;
1160 client->th = NULL; 1158 client->th = NULL;
1159 tc = GNUNET_SCHEDULER_get_task_context ();
1161 if (NULL == buf) 1160 if (NULL == buf)
1162 { 1161 {
1163 delay = GNUNET_TIME_absolute_get_remaining (th->timeout); 1162 delay = GNUNET_TIME_absolute_get_remaining (th->timeout);
@@ -1165,7 +1164,7 @@ client_notify (void *cls,
1165 if ( (GNUNET_YES != th->auto_retry) || 1164 if ( (GNUNET_YES != th->auto_retry) ||
1166 (0 == --th->attempts_left) || 1165 (0 == --th->attempts_left) ||
1167 (delay.rel_value_us < 1)|| 1166 (delay.rel_value_us < 1)||
1168 (0 != (GNUNET_SCHEDULER_get_reason() & GNUNET_SCHEDULER_REASON_SHUTDOWN))) 1167 (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)))
1169 { 1168 {
1170 LOG (GNUNET_ERROR_TYPE_DEBUG, 1169 LOG (GNUNET_ERROR_TYPE_DEBUG,
1171 "Transmission failed %u times, giving up.\n", 1170 "Transmission failed %u times, giving up.\n",
diff --git a/src/util/client_manager.c b/src/util/client_manager.c
index 12c37b23f..f334bb5b6 100644
--- a/src/util/client_manager.c
+++ b/src/util/client_manager.c
@@ -240,7 +240,7 @@ transmit_next (struct GNUNET_CLIENT_MANAGER_Connection *mgr);
240 240
241 241
242static void 242static void
243schedule_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 243schedule_disconnect (void *cls)
244{ 244{
245 struct GNUNET_CLIENT_MANAGER_Connection *mgr = cls; 245 struct GNUNET_CLIENT_MANAGER_Connection *mgr = cls;
246 GNUNET_CLIENT_MANAGER_disconnect (mgr, GNUNET_NO, 246 GNUNET_CLIENT_MANAGER_disconnect (mgr, GNUNET_NO,
@@ -341,11 +341,9 @@ transmit_next (struct GNUNET_CLIENT_MANAGER_Connection *mgr)
341 * 341 *
342 * @param cls 342 * @param cls
343 * Channel handle. 343 * Channel handle.
344 * @param tc
345 * Scheduler context.
346 */ 344 */
347static void 345static void
348schedule_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 346schedule_reconnect (void *cls)
349{ 347{
350 struct GNUNET_CLIENT_MANAGER_Connection *mgr = cls; 348 struct GNUNET_CLIENT_MANAGER_Connection *mgr = cls;
351 mgr->reconnect_task = NULL; 349 mgr->reconnect_task = NULL;
diff --git a/src/util/connection.c b/src/util/connection.c
index 5aa277546..b3ea3b5af 100644
--- a/src/util/connection.c
+++ b/src/util/connection.c
@@ -606,10 +606,9 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *connection)
606 * We are ready to transmit (or got a timeout). 606 * We are ready to transmit (or got a timeout).
607 * 607 *
608 * @param cls our connection handle 608 * @param cls our connection handle
609 * @param tc task context describing why we are here
610 */ 609 */
611static void 610static void
612transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 611transmit_ready (void *cls);
613 612
614 613
615/** 614/**
@@ -617,10 +616,9 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
617 * to read. 616 * to read.
618 * 617 *
619 * @param cls connection to read from 618 * @param cls connection to read from
620 * @param tc scheduler context
621 */ 619 */
622static void 620static void
623receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 621receive_ready (void *cls);
624 622
625 623
626/** 624/**
@@ -668,15 +666,14 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *connection)
668 * Scheduler let us know that we're either ready to write on the 666 * Scheduler let us know that we're either ready to write on the
669 * socket OR connect timed out. Do the right thing. 667 * socket OR connect timed out. Do the right thing.
670 * 668 *
671 * @param cls the "struct AddressProbe*" with the address that we are probing 669 * @param cls the `struct AddressProbe *` with the address that we are probing
672 * @param tc success or failure info about the connect attempt.
673 */ 670 */
674static void 671static void
675connect_probe_continuation (void *cls, 672connect_probe_continuation (void *cls)
676 const struct GNUNET_SCHEDULER_TaskContext *tc)
677{ 673{
678 struct AddressProbe *ap = cls; 674 struct AddressProbe *ap = cls;
679 struct GNUNET_CONNECTION_Handle *connection = ap->connection; 675 struct GNUNET_CONNECTION_Handle *connection = ap->connection;
676 const struct GNUNET_SCHEDULER_TaskContext *tc;
680 struct AddressProbe *pos; 677 struct AddressProbe *pos;
681 int error; 678 int error;
682 socklen_t len; 679 socklen_t len;
@@ -686,6 +683,7 @@ connect_probe_continuation (void *cls,
686 len = sizeof (error); 683 len = sizeof (error);
687 errno = 0; 684 errno = 0;
688 error = 0; 685 error = 0;
686 tc = GNUNET_SCHEDULER_get_task_context ();
689 if ((0 == (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) || 687 if ((0 == (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) ||
690 (GNUNET_OK != 688 (GNUNET_OK !=
691 GNUNET_NETWORK_socket_getsockopt (ap->sock, SOL_SOCKET, SO_ERROR, &error, 689 GNUNET_NETWORK_socket_getsockopt (ap->sock, SOL_SOCKET, SO_ERROR, &error,
@@ -1095,18 +1093,18 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *connection)
1095 * or have data ready to read. 1093 * or have data ready to read.
1096 * 1094 *
1097 * @param cls connection to read from 1095 * @param cls connection to read from
1098 * @param tc scheduler context
1099 */ 1096 */
1100static void 1097static void
1101receive_ready (void *cls, 1098receive_ready (void *cls)
1102 const struct GNUNET_SCHEDULER_TaskContext *tc)
1103{ 1099{
1104 struct GNUNET_CONNECTION_Handle *connection = cls; 1100 struct GNUNET_CONNECTION_Handle *connection = cls;
1101 const struct GNUNET_SCHEDULER_TaskContext *tc;
1105 char buffer[connection->max]; 1102 char buffer[connection->max];
1106 ssize_t ret; 1103 ssize_t ret;
1107 GNUNET_CONNECTION_Receiver receiver; 1104 GNUNET_CONNECTION_Receiver receiver;
1108 1105
1109 connection->read_task = NULL; 1106 connection->read_task = NULL;
1107 tc = GNUNET_SCHEDULER_get_task_context ();
1110 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1108 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1111 { 1109 {
1112 /* ignore shutdown request, go again immediately */ 1110 /* ignore shutdown request, go again immediately */
@@ -1296,11 +1294,9 @@ process_notify (struct GNUNET_CONNECTION_Handle *connection)
1296 * This task notifies the client about the timeout. 1294 * This task notifies the client about the timeout.
1297 * 1295 *
1298 * @param cls the `struct GNUNET_CONNECTION_Handle` 1296 * @param cls the `struct GNUNET_CONNECTION_Handle`
1299 * @param tc scheduler context
1300 */ 1297 */
1301static void 1298static void
1302transmit_timeout (void *cls, 1299transmit_timeout (void *cls)
1303 const struct GNUNET_SCHEDULER_TaskContext *tc)
1304{ 1300{
1305 struct GNUNET_CONNECTION_Handle *connection = cls; 1301 struct GNUNET_CONNECTION_Handle *connection = cls;
1306 GNUNET_CONNECTION_TransmitReadyNotify notify; 1302 GNUNET_CONNECTION_TransmitReadyNotify notify;
@@ -1327,11 +1323,9 @@ transmit_timeout (void *cls,
1327 * This task notifies the client about the error. 1323 * This task notifies the client about the error.
1328 * 1324 *
1329 * @param cls the `struct GNUNET_CONNECTION_Handle` 1325 * @param cls the `struct GNUNET_CONNECTION_Handle`
1330 * @param tc scheduler context
1331 */ 1326 */
1332static void 1327static void
1333connect_error (void *cls, 1328connect_error (void *cls)
1334 const struct GNUNET_SCHEDULER_TaskContext *tc)
1335{ 1329{
1336 struct GNUNET_CONNECTION_Handle *connection = cls; 1330 struct GNUNET_CONNECTION_Handle *connection = cls;
1337 GNUNET_CONNECTION_TransmitReadyNotify notify; 1331 GNUNET_CONNECTION_TransmitReadyNotify notify;
@@ -1353,14 +1347,13 @@ connect_error (void *cls,
1353 * We are ready to transmit (or got a timeout). 1347 * We are ready to transmit (or got a timeout).
1354 * 1348 *
1355 * @param cls our connection handle 1349 * @param cls our connection handle
1356 * @param tc task context describing why we are here
1357 */ 1350 */
1358static void 1351static void
1359transmit_ready (void *cls, 1352transmit_ready (void *cls)
1360 const struct GNUNET_SCHEDULER_TaskContext *tc)
1361{ 1353{
1362 struct GNUNET_CONNECTION_Handle *connection = cls; 1354 struct GNUNET_CONNECTION_Handle *connection = cls;
1363 GNUNET_CONNECTION_TransmitReadyNotify notify; 1355 GNUNET_CONNECTION_TransmitReadyNotify notify;
1356 const struct GNUNET_SCHEDULER_TaskContext *tc;
1364 ssize_t ret; 1357 ssize_t ret;
1365 size_t have; 1358 size_t have;
1366 1359
@@ -1370,6 +1363,7 @@ transmit_ready (void *cls,
1370 GNUNET_assert (NULL != connection->write_task); 1363 GNUNET_assert (NULL != connection->write_task);
1371 connection->write_task = NULL; 1364 connection->write_task = NULL;
1372 GNUNET_assert (NULL == connection->nth.timeout_task); 1365 GNUNET_assert (NULL == connection->nth.timeout_task);
1366 tc = GNUNET_SCHEDULER_get_task_context ();
1373 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1367 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1374 { 1368 {
1375 if (NULL != connection->sock) 1369 if (NULL != connection->sock)
diff --git a/src/util/crypto_hash_file.c b/src/util/crypto_hash_file.c
index 8bb03561b..f2d49d164 100644
--- a/src/util/crypto_hash_file.c
+++ b/src/util/crypto_hash_file.c
@@ -117,10 +117,9 @@ file_hash_finish (struct GNUNET_CRYPTO_FileHashContext *fhc,
117 * File hashing task. 117 * File hashing task.
118 * 118 *
119 * @param cls closure 119 * @param cls closure
120 * @param tc context
121 */ 120 */
122static void 121static void
123file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 122file_hash_task (void *cls)
124{ 123{
125 struct GNUNET_CRYPTO_FileHashContext *fhc = cls; 124 struct GNUNET_CRYPTO_FileHashContext *fhc = cls;
126 struct GNUNET_HashCode *res; 125 struct GNUNET_HashCode *res;
diff --git a/src/util/disk_iterator.c b/src/util/disk_iterator.c
index 925d4c6fd..2315f2861 100644
--- a/src/util/disk_iterator.c
+++ b/src/util/disk_iterator.c
@@ -77,8 +77,7 @@ struct GNUNET_DISK_DirectoryIterator
77 * Task used by the directory iterator. 77 * Task used by the directory iterator.
78 */ 78 */
79static void 79static void
80directory_iterator_task (void *cls, 80directory_iterator_task (void *cls)
81 const struct GNUNET_SCHEDULER_TaskContext *tc)
82{ 81{
83 struct GNUNET_DISK_DirectoryIterator *iter = cls; 82 struct GNUNET_DISK_DirectoryIterator *iter = cls;
84 char *name; 83 char *name;
diff --git a/src/util/gnunet-scrypt.c b/src/util/gnunet-scrypt.c
index 434574ef0..7449d8042 100644
--- a/src/util/gnunet-scrypt.c
+++ b/src/util/gnunet-scrypt.c
@@ -110,8 +110,7 @@ count_leading_zeroes (const struct GNUNET_HashCode *hash)
110 * @param tc task context 110 * @param tc task context
111 */ 111 */
112static void 112static void
113find_proof (void *cls, 113find_proof (void *cls)
114 const struct GNUNET_SCHEDULER_TaskContext *tc)
115{ 114{
116 #define ROUND_SIZE 10 115 #define ROUND_SIZE 10
117 uint64_t counter; 116 uint64_t counter;
@@ -121,7 +120,9 @@ find_proof (void *cls,
121 unsigned int i; 120 unsigned int i;
122 struct GNUNET_TIME_Absolute timestamp; 121 struct GNUNET_TIME_Absolute timestamp;
123 struct GNUNET_TIME_Relative elapsed; 122 struct GNUNET_TIME_Relative elapsed;
123 const struct GNUNET_SCHEDULER_TaskContext *tc;
124 124
125 tc = GNUNET_SCHEDULER_get_task_context ();
125 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) 126 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
126 { 127 {
127 write_proof (); 128 write_proof ();
diff --git a/src/util/gnunet-uri.c b/src/util/gnunet-uri.c
index ada67e310..75e70d2b7 100644
--- a/src/util/gnunet-uri.c
+++ b/src/util/gnunet-uri.c
@@ -47,10 +47,9 @@ static struct GNUNET_DISK_PipeHandle *sigpipe;
47 * process died) or when user presses CTRL-C. 47 * process died) or when user presses CTRL-C.
48 * 48 *
49 * @param cls closure, NULL 49 * @param cls closure, NULL
50 * @param tc scheduler context
51 */ 50 */
52static void 51static void
53maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 52maint_child_death (void *cls)
54{ 53{
55 enum GNUNET_OS_ProcessStatusType type; 54 enum GNUNET_OS_ProcessStatusType type;
56 if ( (GNUNET_OK != 55 if ( (GNUNET_OK !=
diff --git a/src/util/helper.c b/src/util/helper.c
index f0123460b..3ed1c7276 100644
--- a/src/util/helper.c
+++ b/src/util/helper.c
@@ -138,7 +138,7 @@ struct GNUNET_HELPER_Handle
138 * NULL-terminated list of command-line arguments. 138 * NULL-terminated list of command-line arguments.
139 */ 139 */
140 char **binary_argv; 140 char **binary_argv;
141 141
142 /** 142 /**
143 * Task to read from the helper. 143 * Task to read from the helper.
144 */ 144 */
@@ -305,28 +305,26 @@ stop_helper (struct GNUNET_HELPER_Handle *h,
305 * Restart the helper process. 305 * Restart the helper process.
306 * 306 *
307 * @param cls handle to the helper process 307 * @param cls handle to the helper process
308 * @param tc scheduler context
309 */ 308 */
310static void 309static void
311restart_task (void *cls, 310restart_task (void *cls);
312 const struct GNUNET_SCHEDULER_TaskContext *tc);
313 311
314 312
315/** 313/**
316 * Read from the helper-process 314 * Read from the helper-process
317 * 315 *
318 * @param cls handle to the helper process 316 * @param cls handle to the helper process
319 * @param tc scheduler context
320 */ 317 */
321static void 318static void
322helper_read (void *cls, 319helper_read (void *cls)
323 const struct GNUNET_SCHEDULER_TaskContext *tc)
324{ 320{
325 struct GNUNET_HELPER_Handle *h = cls; 321 struct GNUNET_HELPER_Handle *h = cls;
322 const struct GNUNET_SCHEDULER_TaskContext *tc;
326 char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE] GNUNET_ALIGN; 323 char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE] GNUNET_ALIGN;
327 ssize_t t; 324 ssize_t t;
328 325
329 h->read_task = NULL; 326 h->read_task = NULL;
327 tc = GNUNET_SCHEDULER_get_task_context ();
330 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 328 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
331 { 329 {
332 /* try again */ 330 /* try again */
@@ -458,17 +456,15 @@ start_helper (struct GNUNET_HELPER_Handle *h)
458 * Restart the helper process. 456 * Restart the helper process.
459 * 457 *
460 * @param cls handle to the helper process 458 * @param cls handle to the helper process
461 * @param tc scheduler context
462 */ 459 */
463static void 460static void
464restart_task (void *cls, 461restart_task (void *cls)
465 const struct GNUNET_SCHEDULER_TaskContext *tc)
466{ 462{
467 struct GNUNET_HELPER_Handle*h = cls; 463 struct GNUNET_HELPER_Handle*h = cls;
468 464
469 h->restart_task = NULL; 465 h->restart_task = NULL;
470 h->retry_back_off++; 466 h->retry_back_off++;
471 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 467 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
472 "Restarting helper with back-off %u\n", 468 "Restarting helper with back-off %u\n",
473 h->retry_back_off); 469 h->retry_back_off);
474 start_helper (h); 470 start_helper (h);
@@ -582,18 +578,18 @@ GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h,
582 * Write to the helper-process 578 * Write to the helper-process
583 * 579 *
584 * @param cls handle to the helper process 580 * @param cls handle to the helper process
585 * @param tc scheduler context
586 */ 581 */
587static void 582static void
588helper_write (void *cls, 583helper_write (void *cls)
589 const struct GNUNET_SCHEDULER_TaskContext *tc)
590{ 584{
591 struct GNUNET_HELPER_Handle *h = cls; 585 struct GNUNET_HELPER_Handle *h = cls;
586 const struct GNUNET_SCHEDULER_TaskContext *tc;
592 struct GNUNET_HELPER_SendHandle *sh; 587 struct GNUNET_HELPER_SendHandle *sh;
593 const char *buf; 588 const char *buf;
594 ssize_t t; 589 ssize_t t;
595 590
596 h->write_task = NULL; 591 h->write_task = NULL;
592 tc = GNUNET_SCHEDULER_get_task_context ();
597 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 593 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
598 { 594 {
599 /* try again */ 595 /* try again */
diff --git a/src/util/mq.c b/src/util/mq.c
index f5ebe33a5..aff9f465c 100644
--- a/src/util/mq.c
+++ b/src/util/mq.c
@@ -297,15 +297,15 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq,
297 * results in undefined behavior if not used carefully. 297 * results in undefined behavior if not used carefully.
298 * 298 *
299 * @param cls message queue to send the next message with 299 * @param cls message queue to send the next message with
300 * @param tc scheduler context
301 */ 300 */
302static void 301static void
303impl_send_continue (void *cls, 302impl_send_continue (void *cls)
304 const struct GNUNET_SCHEDULER_TaskContext *tc)
305{ 303{
306 struct GNUNET_MQ_Handle *mq = cls; 304 struct GNUNET_MQ_Handle *mq = cls;
305 const struct GNUNET_SCHEDULER_TaskContext *tc;
307 struct GNUNET_MQ_Envelope *current_envelope; 306 struct GNUNET_MQ_Envelope *current_envelope;
308 307
308 tc = GNUNET_SCHEDULER_get_task_context ();
309 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 309 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
310 return; 310 return;
311 311
diff --git a/src/util/os_priority.c b/src/util/os_priority.c
index 52e2f6d0e..8dfec6c5e 100644
--- a/src/util/os_priority.c
+++ b/src/util/os_priority.c
@@ -70,18 +70,19 @@ static struct GNUNET_OS_Process current_process;
70 * This handler is called when there are control data to be read on the pipe 70 * This handler is called when there are control data to be read on the pipe
71 * 71 *
72 * @param cls the 'struct GNUNET_DISK_FileHandle' of the control pipe 72 * @param cls the 'struct GNUNET_DISK_FileHandle' of the control pipe
73 * @param tc scheduler context
74 */ 73 */
75static void 74static void
76parent_control_handler (void *cls, 75parent_control_handler (void *cls)
77 const struct GNUNET_SCHEDULER_TaskContext *tc)
78{ 76{
79 struct GNUNET_DISK_FileHandle *control_pipe = cls; 77 struct GNUNET_DISK_FileHandle *control_pipe = cls;
78 const struct GNUNET_SCHEDULER_TaskContext *tc;
80 char sig; 79 char sig;
81 char *pipe_fd; 80 char *pipe_fd;
82 ssize_t ret; 81 ssize_t ret;
83 82
84 LOG (GNUNET_ERROR_TYPE_DEBUG, "`%s' invoked because of %d\n", __FUNCTION__, 83 tc = GNUNET_SCHEDULER_get_task_context ();
84 LOG (GNUNET_ERROR_TYPE_DEBUG,
85 "`%s' invoked because of %d\n", __FUNCTION__,
85 tc->reason); 86 tc->reason);
86 if (0 != (tc->reason & 87 if (0 != (tc->reason &
87 (GNUNET_SCHEDULER_REASON_SHUTDOWN | GNUNET_SCHEDULER_REASON_TIMEOUT))) 88 (GNUNET_SCHEDULER_REASON_SHUTDOWN | GNUNET_SCHEDULER_REASON_TIMEOUT)))
@@ -118,12 +119,9 @@ parent_control_handler (void *cls,
118 * variable) and raise those signals. 119 * variable) and raise those signals.
119 * 120 *
120 * @param cls closure (unused) 121 * @param cls closure (unused)
121 * @param tc scheduler context (unused)
122 */ 122 */
123void 123void
124GNUNET_OS_install_parent_control_handler (void *cls, 124GNUNET_OS_install_parent_control_handler (void *cls)
125 const struct
126 GNUNET_SCHEDULER_TaskContext *tc)
127{ 125{
128 const char *env_buf; 126 const char *env_buf;
129 char *env_buf_end; 127 char *env_buf_end;
@@ -1751,18 +1749,19 @@ GNUNET_OS_command_stop (struct GNUNET_OS_CommandHandle *cmd)
1751/** 1749/**
1752 * Read from the process and call the line processor. 1750 * Read from the process and call the line processor.
1753 * 1751 *
1754 * @param cls the 'struct GNUNET_OS_CommandHandle' 1752 * @param cls the `struct GNUNET_OS_CommandHandle *`
1755 * @param tc scheduler context
1756 */ 1753 */
1757static void 1754static void
1758cmd_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1755cmd_read (void *cls)
1759{ 1756{
1760 struct GNUNET_OS_CommandHandle *cmd = cls; 1757 struct GNUNET_OS_CommandHandle *cmd = cls;
1758 const struct GNUNET_SCHEDULER_TaskContext *tc;
1761 GNUNET_OS_LineProcessor proc; 1759 GNUNET_OS_LineProcessor proc;
1762 char *end; 1760 char *end;
1763 ssize_t ret; 1761 ssize_t ret;
1764 1762
1765 cmd->rtask = NULL; 1763 cmd->rtask = NULL;
1764 tc = GNUNET_SCHEDULER_get_task_context ();
1766 if (GNUNET_YES != GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, cmd->r)) 1765 if (GNUNET_YES != GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, cmd->r))
1767 { 1766 {
1768 /* timeout, shutdown, etc. */ 1767 /* timeout, shutdown, etc. */
diff --git a/src/util/program.c b/src/util/program.c
index 7023552f6..69dd455cd 100644
--- a/src/util/program.c
+++ b/src/util/program.c
@@ -73,10 +73,12 @@ struct CommandContext
73 * program. Runs the program-specific main task. 73 * program. Runs the program-specific main task.
74 */ 74 */
75static void 75static void
76program_main (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 76program_main (void *cls)
77{ 77{
78 struct CommandContext *cc = cls; 78 struct CommandContext *cc = cls;
79 const struct GNUNET_SCHEDULER_TaskContext *tc;
79 80
81 tc = GNUNET_SCHEDULER_get_task_context ();
80 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) 82 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
81 return; 83 return;
82 GNUNET_SPEEDUP_start_(cc->cfg); 84 GNUNET_SPEEDUP_start_(cc->cfg);
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c
index 81ec01af4..e7a836f03 100644
--- a/src/util/resolver_api.c
+++ b/src/util/resolver_api.c
@@ -532,11 +532,9 @@ handle_response (void *cls,
532 * numeric addresses. 532 * numeric addresses.
533 * 533 *
534 * @param cls `struct GNUNET_RESOLVER_RequestHandle` for the request 534 * @param cls `struct GNUNET_RESOLVER_RequestHandle` for the request
535 * @param tc unused scheduler context
536 */ 535 */
537static void 536static void
538numeric_resolution (void *cls, 537numeric_resolution (void *cls)
539 const struct GNUNET_SCHEDULER_TaskContext *tc)
540{ 538{
541 struct GNUNET_RESOLVER_RequestHandle *rh = cls; 539 struct GNUNET_RESOLVER_RequestHandle *rh = cls;
542 struct sockaddr_in v4; 540 struct sockaddr_in v4;
@@ -600,11 +598,9 @@ numeric_resolution (void *cls,
600 * respective loopback numeric addresses. 598 * respective loopback numeric addresses.
601 * 599 *
602 * @param cls `struct GNUNET_RESOLVER_RequestHandle` for the request 600 * @param cls `struct GNUNET_RESOLVER_RequestHandle` for the request
603 * @param tc unused scheduler context
604 */ 601 */
605static void 602static void
606loopback_resolution (void *cls, 603loopback_resolution (void *cls)
607 const struct GNUNET_SCHEDULER_TaskContext *tc)
608{ 604{
609 struct GNUNET_RESOLVER_RequestHandle *rh = cls; 605 struct GNUNET_RESOLVER_RequestHandle *rh = cls;
610 struct sockaddr_in v4; 606 struct sockaddr_in v4;
@@ -658,8 +654,7 @@ loopback_resolution (void *cls,
658 * Task executed on system shutdown. 654 * Task executed on system shutdown.
659 */ 655 */
660static void 656static void
661shutdown_task (void *cls, 657shutdown_task (void *cls)
662 const struct GNUNET_SCHEDULER_TaskContext *tc)
663{ 658{
664 s_task = NULL; 659 s_task = NULL;
665 GNUNET_RESOLVER_disconnect (); 660 GNUNET_RESOLVER_disconnect ();
@@ -728,15 +723,16 @@ process_requests ()
728 * Now try to reconnect to the resolver service. 723 * Now try to reconnect to the resolver service.
729 * 724 *
730 * @param cls NULL 725 * @param cls NULL
731 * @param tc scheduler context
732 */ 726 */
733static void 727static void
734reconnect_task (void *cls, 728reconnect_task (void *cls)
735 const struct GNUNET_SCHEDULER_TaskContext *tc)
736{ 729{
730 const struct GNUNET_SCHEDULER_TaskContext *tc;
731
737 r_task = NULL; 732 r_task = NULL;
738 if (NULL == req_head) 733 if (NULL == req_head)
739 return; /* no work pending */ 734 return; /* no work pending */
735 tc = GNUNET_SCHEDULER_get_task_context ();
740 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 736 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
741 return; 737 return;
742 LOG (GNUNET_ERROR_TYPE_DEBUG, 738 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -802,11 +798,9 @@ reconnect ()
802 * A DNS resolution timed out. Notify the application. 798 * A DNS resolution timed out. Notify the application.
803 * 799 *
804 * @param cls the `struct GNUNET_RESOLVER_RequestHandle *` 800 * @param cls the `struct GNUNET_RESOLVER_RequestHandle *`
805 * @param tc scheduler context
806 */ 801 */
807static void 802static void
808handle_lookup_timeout (void *cls, 803handle_lookup_timeout (void *cls)
809 const struct GNUNET_SCHEDULER_TaskContext *tc)
810{ 804{
811 struct GNUNET_RESOLVER_RequestHandle *rh = cls; 805 struct GNUNET_RESOLVER_RequestHandle *rh = cls;
812 806
@@ -902,11 +896,9 @@ GNUNET_RESOLVER_ip_get (const char *hostname,
902 * conversion and invoke the callback. 896 * conversion and invoke the callback.
903 * 897 *
904 * @param cls `struct GNUNET_RESOLVER_RequestHandle` for the request 898 * @param cls `struct GNUNET_RESOLVER_RequestHandle` for the request
905 * @param tc unused scheduler context
906 */ 899 */
907static void 900static void
908numeric_reverse (void *cls, 901numeric_reverse (void *cls)
909 const struct GNUNET_SCHEDULER_TaskContext *tc)
910{ 902{
911 struct GNUNET_RESOLVER_RequestHandle *rh = cls; 903 struct GNUNET_RESOLVER_RequestHandle *rh = cls;
912 char *result; 904 char *result;
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 6405ea336..dcf5aeeaa 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -256,6 +256,11 @@ static int current_lifeness;
256static GNUNET_SCHEDULER_select scheduler_select; 256static GNUNET_SCHEDULER_select scheduler_select;
257 257
258/** 258/**
259 * Task context of the current task.
260 */
261static struct GNUNET_SCHEDULER_TaskContext tc;
262
263/**
259 * Closure for #scheduler_select. 264 * Closure for #scheduler_select.
260 */ 265 */
261static void *scheduler_select_cls; 266static void *scheduler_select_cls;
@@ -533,7 +538,6 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs,
533{ 538{
534 enum GNUNET_SCHEDULER_Priority p; 539 enum GNUNET_SCHEDULER_Priority p;
535 struct GNUNET_SCHEDULER_Task *pos; 540 struct GNUNET_SCHEDULER_Task *pos;
536 struct GNUNET_SCHEDULER_TaskContext tc;
537 541
538 max_priority_added = GNUNET_SCHEDULER_PRIORITY_KEEP; 542 max_priority_added = GNUNET_SCHEDULER_PRIORITY_KEEP;
539 do 543 do
@@ -584,7 +588,7 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs,
584 LOG (GNUNET_ERROR_TYPE_DEBUG, 588 LOG (GNUNET_ERROR_TYPE_DEBUG,
585 "Running task: %p\n", 589 "Running task: %p\n",
586 pos); 590 pos);
587 pos->callback (pos->callback_cls, &tc); 591 pos->callback (pos->callback_cls);
588#if EXECINFO 592#if EXECINFO
589 unsigned int i; 593 unsigned int i;
590 594
@@ -902,17 +906,16 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task,
902 906
903 907
904/** 908/**
905 * Obtain the reason code for why the current task was 909 * Obtain the task context, giving the reason why the current task was
906 * started. Will return the same value as 910 * started.
907 * the `struct GNUNET_SCHEDULER_TaskContext`'s reason field.
908 * 911 *
909 * @return reason(s) why the current task is run 912 * @return current tasks' scheduler context
910 */ 913 */
911enum GNUNET_SCHEDULER_Reason 914const struct GNUNET_SCHEDULER_TaskContext *
912GNUNET_SCHEDULER_get_reason () 915GNUNET_SCHEDULER_get_task_context ()
913{ 916{
914 GNUNET_assert (NULL != active_task); 917 GNUNET_assert (NULL != active_task);
915 return active_task->reason; 918 return &tc;
916} 919}
917 920
918 921
diff --git a/src/util/server.c b/src/util/server.c
index 0433feb58..8dedd28fd 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -389,17 +389,17 @@ GNUNET_SERVER_client_set_user_context_ (struct GNUNET_SERVER_Client *client,
389 * 389 *
390 * @param cls handle to our server for which we are processing the listen 390 * @param cls handle to our server for which we are processing the listen
391 * socket 391 * socket
392 * @param tc reason why we are running right now
393 */ 392 */
394static void 393static void
395process_listen_socket (void *cls, 394process_listen_socket (void *cls)
396 const struct GNUNET_SCHEDULER_TaskContext *tc)
397{ 395{
398 struct GNUNET_SERVER_Handle *server = cls; 396 struct GNUNET_SERVER_Handle *server = cls;
397 const struct GNUNET_SCHEDULER_TaskContext *tc;
399 struct GNUNET_CONNECTION_Handle *sock; 398 struct GNUNET_CONNECTION_Handle *sock;
400 unsigned int i; 399 unsigned int i;
401 400
402 server->listen_task = NULL; 401 server->listen_task = NULL;
402 tc = GNUNET_SCHEDULER_get_task_context ();
403 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 403 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
404 { 404 {
405 /* ignore shutdown, someone else will take care of it! */ 405 /* ignore shutdown, someone else will take care of it! */
@@ -655,12 +655,10 @@ GNUNET_SERVER_client_mark_monitor (struct GNUNET_SERVER_Client *client)
655 * Helper function for #test_monitor_clients() to trigger 655 * Helper function for #test_monitor_clients() to trigger
656 * #GNUNET_SERVER_destroy() after the stack has unwound. 656 * #GNUNET_SERVER_destroy() after the stack has unwound.
657 * 657 *
658 * @param cls the 'struct GNUNET_SERVER_Handle' to destroy 658 * @param cls the `struct GNUNET_SERVER_Handle *` to destroy
659 * @param tc unused
660 */ 659 */
661static void 660static void
662do_destroy (void *cls, 661do_destroy (void *cls)
663 const struct GNUNET_SCHEDULER_TaskContext *tc)
664{ 662{
665 struct GNUNET_SERVER_Handle *server = cls; 663 struct GNUNET_SERVER_Handle *server = cls;
666 664
@@ -887,18 +885,18 @@ GNUNET_SERVER_set_callbacks (struct GNUNET_SERVER_Handle *server,
887 * Task run to warn about missing calls to #GNUNET_SERVER_receive_done. 885 * Task run to warn about missing calls to #GNUNET_SERVER_receive_done.
888 * 886 *
889 * @param cls our `struct GNUNET_SERVER_Client *` to process more requests from 887 * @param cls our `struct GNUNET_SERVER_Client *` to process more requests from
890 * @param tc scheduler context (unused)
891 */ 888 */
892static void 889static void
893warn_no_receive_done (void *cls, 890warn_no_receive_done (void *cls)
894 const struct GNUNET_SCHEDULER_TaskContext *tc)
895{ 891{
896 struct GNUNET_SERVER_Client *client = cls; 892 struct GNUNET_SERVER_Client *client = cls;
893 const struct GNUNET_SCHEDULER_TaskContext *tc;
897 894
898 GNUNET_break (0 != client->warn_type); /* type should never be 0 here, as we don't use 0 */ 895 GNUNET_break (0 != client->warn_type); /* type should never be 0 here, as we don't use 0 */
899 client->warn_task = 896 client->warn_task =
900 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, 897 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
901 &warn_no_receive_done, client); 898 &warn_no_receive_done, client);
899 tc = GNUNET_SCHEDULER_get_task_context ();
902 if (0 == (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) 900 if (0 == (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
903 LOG (GNUNET_ERROR_TYPE_WARNING, 901 LOG (GNUNET_ERROR_TYPE_WARNING,
904 _("Processing code for message of type %u did not call `GNUNET_SERVER_receive_done' after %s\n"), 902 _("Processing code for message of type %u did not call `GNUNET_SERVER_receive_done' after %s\n"),
@@ -1199,11 +1197,9 @@ process_incoming (void *cls,
1199 * and process requests. 1197 * and process requests.
1200 * 1198 *
1201 * @param cls our `struct GNUNET_SERVER_Client *` to process more requests from 1199 * @param cls our `struct GNUNET_SERVER_Client *` to process more requests from
1202 * @param tc scheduler context (unused)
1203 */ 1200 */
1204static void 1201static void
1205restart_processing (void *cls, 1202restart_processing (void *cls)
1206 const struct GNUNET_SCHEDULER_TaskContext *tc)
1207{ 1203{
1208 struct GNUNET_SERVER_Client *client = cls; 1204 struct GNUNET_SERVER_Client *client = cls;
1209 1205
@@ -1497,11 +1493,9 @@ GNUNET_SERVER_connect_notify_cancel (struct GNUNET_SERVER_Handle *server,
1497 * 'connection.c' is not allowed (see #2329). 1493 * 'connection.c' is not allowed (see #2329).
1498 * 1494 *
1499 * @param cls connection to destroy 1495 * @param cls connection to destroy
1500 * @param tc scheduler context (unused)
1501 */ 1496 */
1502static void 1497static void
1503destroy_connection (void *cls, 1498destroy_connection (void *cls)
1504 const struct GNUNET_SCHEDULER_TaskContext *tc)
1505{ 1499{
1506 struct GNUNET_CONNECTION_Handle *connection = cls; 1500 struct GNUNET_CONNECTION_Handle *connection = cls;
1507 1501
diff --git a/src/util/service.c b/src/util/service.c
index be3b4442a..76e540302 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -1126,11 +1126,9 @@ write_pid_file (struct GNUNET_SERVICE_Context *sctx, pid_t pid)
1126 * Task run during shutdown. Stops the server/service. 1126 * Task run during shutdown. Stops the server/service.
1127 * 1127 *
1128 * @param cls the `struct GNUNET_SERVICE_Context` 1128 * @param cls the `struct GNUNET_SERVICE_Context`
1129 * @param tc unused
1130 */ 1129 */
1131static void 1130static void
1132shutdown_task (void *cls, 1131shutdown_task (void *cls)
1133 const struct GNUNET_SCHEDULER_TaskContext *tc)
1134{ 1132{
1135 struct GNUNET_SERVICE_Context *service = cls; 1133 struct GNUNET_SERVICE_Context *service = cls;
1136 struct GNUNET_SERVER_Handle *server = service->server; 1134 struct GNUNET_SERVER_Handle *server = service->server;
@@ -1147,14 +1145,15 @@ shutdown_task (void *cls,
1147 * Initial task for the service. 1145 * Initial task for the service.
1148 * 1146 *
1149 * @param cls service context 1147 * @param cls service context
1150 * @param tc unused
1151 */ 1148 */
1152static void 1149static void
1153service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1150service_task (void *cls)
1154{ 1151{
1155 struct GNUNET_SERVICE_Context *sctx = cls; 1152 struct GNUNET_SERVICE_Context *sctx = cls;
1156 unsigned int i; 1153 unsigned int i;
1154 const struct GNUNET_SCHEDULER_TaskContext *tc;
1157 1155
1156 tc = GNUNET_SCHEDULER_get_task_context ();
1158 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) 1157 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
1159 return; 1158 return;
1160 (void) GNUNET_SPEEDUP_start_ (sctx->cfg); 1159 (void) GNUNET_SPEEDUP_start_ (sctx->cfg);
diff --git a/src/util/socks.c b/src/util/socks.c
index 3fa18cca9..cc59858dd 100644
--- a/src/util/socks.c
+++ b/src/util/socks.c
@@ -105,7 +105,7 @@ unsigned char * SOCK5_proto_string(unsigned char * b, const char * s)
105/** 105/**
106 * State of the SOCKS5 handshake. 106 * State of the SOCKS5 handshake.
107 */ 107 */
108struct GNUNET_SOCKS_Handshake 108struct GNUNET_SOCKS_Handshake
109{ 109{
110 110
111 /** 111 /**
@@ -124,7 +124,7 @@ struct GNUNET_SOCKS_Handshake
124 struct GNUNET_CONNECTION_TransmitHandle *th; 124 struct GNUNET_CONNECTION_TransmitHandle *th;
125 125
126 /** 126 /**
127 * Our stage in the SOCKS5 handshake 127 * Our stage in the SOCKS5 handshake
128 */ 128 */
129 int step; 129 int step;
130 130
@@ -199,7 +199,7 @@ SOCKS5_handshake_step (struct GNUNET_SOCKS_Handshake *ih)
199 GNUNET_assert (SOCKS5_step_done > ih->step && ih->step >= 0); 199 GNUNET_assert (SOCKS5_step_done > ih->step && ih->step >= 0);
200 switch (ih->step) { 200 switch (ih->step) {
201 case SOCKS5_step_greet: /* SOCKS5 server's greeting */ 201 case SOCKS5_step_greet: /* SOCKS5 server's greeting */
202 if (b[0] != 5) 202 if (b[0] != 5)
203 { 203 {
204 LOG (GNUNET_ERROR_TYPE_ERROR, 204 LOG (GNUNET_ERROR_TYPE_ERROR,
205 "Not a SOCKS5 server\n"); 205 "Not a SOCKS5 server\n");
@@ -234,7 +234,7 @@ SOCKS5_handshake_step (struct GNUNET_SOCKS_Handshake *ih)
234 b += 2; 234 b += 2;
235 break; 235 break;
236 case SOCKS5_step_cmd: /* SOCKS5 server's responce to command */ 236 case SOCKS5_step_cmd: /* SOCKS5 server's responce to command */
237 if (b[0] != 5) 237 if (b[0] != 5)
238 { 238 {
239 LOG (GNUNET_ERROR_TYPE_ERROR, 239 LOG (GNUNET_ERROR_TYPE_ERROR,
240 "SOCKS5 protocol error\n"); 240 "SOCKS5 protocol error\n");
@@ -271,11 +271,11 @@ SOCKS5_handshake_step (struct GNUNET_SOCKS_Handshake *ih)
271 ih->instart = b; 271 ih->instart = b;
272 SOCKS5_handshake_done (ih); 272 SOCKS5_handshake_done (ih);
273 return; 273 return;
274 case SOCKS5_step_done: 274 case SOCKS5_step_done:
275 GNUNET_assert (0); 275 GNUNET_assert (0);
276 } 276 }
277 ih->instart = b; 277 ih->instart = b;
278 /* Do not reschedule the sender unless we're done reading. 278 /* Do not reschedule the sender unless we're done reading.
279 * I imagine this lets us avoid ever cancelling the transmit handle. */ 279 * I imagine this lets us avoid ever cancelling the transmit handle. */
280 register_sender (ih); 280 register_sender (ih);
281} 281}
@@ -289,7 +289,7 @@ SOCKS5_handshake_step (struct GNUNET_SOCKS_Handshake *ih)
289 * @param handler_cls closure for @a handler 289 * @param handler_cls closure for @a handler
290 */ 290 */
291void 291void
292reciever (void *cls, 292reciever (void *cls,
293 const void *buf, size_t available, 293 const void *buf, size_t available,
294 const struct sockaddr * addr, 294 const struct sockaddr * addr,
295 socklen_t addrlen, int errCode) 295 socklen_t addrlen, int errCode)
@@ -330,7 +330,7 @@ register_reciever (struct GNUNET_SOCKS_Handshake *ih, int want)
330 */ 330 */
331 331
332size_t 332size_t
333transmit_ready (void *cls, 333transmit_ready (void *cls,
334 size_t size, 334 size_t size,
335 void *buf) 335 void *buf)
336{ 336{
@@ -345,23 +345,28 @@ transmit_ready (void *cls,
345 * GNUNET_CONNECTION_notify_transmit_ready() can schedule : 345 * GNUNET_CONNECTION_notify_transmit_ready() can schedule :
346 * transmit_timeout() - DNS still working 346 * transmit_timeout() - DNS still working
347 * connect_error() - DNS done but no socket? 347 * connect_error() - DNS done but no socket?
348 * transmit_ready() - scheduler shutdown or timeout, or signal_transmit_error() 348 * transmit_ready() - scheduler shutdown or timeout, or signal_transmit_error()
349 * We'd need to dig into the scheduler to guess at the reason, as 349 * We'd need to dig into the scheduler to guess at the reason, as
350 * connection.c tells us nothing itself, but mostly its timouts. 350 * connection.c tells us nothing itself, but mostly its timouts.
351 * Initially, we'll simply ignore this and leave massive timeouts, but 351 * Initially, we'll simply ignore this and leave massive timeouts, but
352 * maybe that should change for error handling pruposes. It appears that 352 * maybe that should change for error handling pruposes. It appears that
353 * successful operations, including DNS resolution, do not use this. */ 353 * successful operations, including DNS resolution, do not use this. */
354 if (NULL==buf) 354 if (NULL == buf)
355 { 355 {
356 enum GNUNET_SCHEDULER_Reason reason = GNUNET_SCHEDULER_get_reason (); 356 const struct GNUNET_SCHEDULER_TaskContext *tc;
357 if (0 != (reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 357
358 tc = GNUNET_SCHEDULER_get_task_context ();
359 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
358 return 0; 360 return 0;
359 if (0 != (reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) { 361 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) {
360 if (0==ih->step) { 362 if (0==ih->step)
363 {
361 LOG (GNUNET_ERROR_TYPE_WARNING, 364 LOG (GNUNET_ERROR_TYPE_WARNING,
362 "Timeout contacting SOCKS server, retrying indefinitely, but probably hopeless.\n"); 365 "Timeout contacting SOCKS server, retrying indefinitely, but probably hopeless.\n");
363 register_sender (ih); 366 register_sender (ih);
364 } else { 367 }
368 else
369 {
365 LOG (GNUNET_ERROR_TYPE_ERROR, 370 LOG (GNUNET_ERROR_TYPE_ERROR,
366 "Timeout during mid SOCKS handshake (step %u), probably not a SOCKS server.\n", 371 "Timeout during mid SOCKS handshake (step %u), probably not a SOCKS server.\n",
367 ih->step); 372 ih->step);
@@ -418,7 +423,7 @@ register_sender (struct GNUNET_SOCKS_Handshake *ih)
418/** 423/**
419 * Initialize a SOCKS5 handshake for authentication via username and 424 * Initialize a SOCKS5 handshake for authentication via username and
420 * password. Tor uses SOCKS username and password authentication to assign 425 * password. Tor uses SOCKS username and password authentication to assign
421 * programs unique circuits. 426 * programs unique circuits.
422 * 427 *
423 * @param user username for the proxy 428 * @param user username for the proxy
424 * @param pass password for the proxy 429 * @param pass password for the proxy
@@ -435,7 +440,7 @@ GNUNET_SOCKS_init_handshake (const char *user, const char *pass)
435 unsigned char * n = b++; 440 unsigned char * n = b++;
436 *n = 1; /* Number of authentication methods */ 441 *n = 1; /* Number of authentication methods */
437 /* We support no authentication even when requesting authentication, 442 /* We support no authentication even when requesting authentication,
438 * but this appears harmless, given the way that Tor uses authentication. 443 * but this appears harmless, given the way that Tor uses authentication.
439 * And some SOCKS5 servers might require this. */ 444 * And some SOCKS5 servers might require this. */
440 *(b++) = SOCKS5_AUTH_NOAUTH; 445 *(b++) = SOCKS5_AUTH_NOAUTH;
441 if (NULL != user) { 446 if (NULL != user) {
@@ -445,7 +450,7 @@ GNUNET_SOCKS_init_handshake (const char *user, const char *pass)
445 /* There is no apperent reason to support authentication methods beyond 450 /* There is no apperent reason to support authentication methods beyond
446 * username and password since afaik Tor does not support them. */ 451 * username and password since afaik Tor does not support them. */
447 452
448 /* We authenticate with an empty username and password if the server demands 453 /* We authenticate with an empty username and password if the server demands
449 * them but we do not have any. */ 454 * them but we do not have any. */
450 if (user == NULL) 455 if (user == NULL)
451 user = ""; 456 user = "";
@@ -466,7 +471,7 @@ GNUNET_SOCKS_init_handshake (const char *user, const char *pass)
466 471
467 472
468/** 473/**
469 * Initialize a SOCKS5 handshake without authentication, thereby possibly 474 * Initialize a SOCKS5 handshake without authentication, thereby possibly
470 * sharing a Tor circuit with another process. 475 * sharing a Tor circuit with another process.
471 * 476 *
472 * @return Valid SOCKS5 hanbdshake handle 477 * @return Valid SOCKS5 hanbdshake handle
@@ -480,11 +485,11 @@ GNUNET_SOCKS_init_handshake_noauth ()
480 485
481/** 486/**
482 * Build request that the SOCKS5 proxy open a TCP/IP stream to the given host 487 * Build request that the SOCKS5 proxy open a TCP/IP stream to the given host
483 * and port. 488 * and port.
484 * 489 *
485 * @param ih SOCKS5 handshake 490 * @param ih SOCKS5 handshake
486 * @param hostname 491 * @param hostname
487 * @param port 492 * @param port
488 */ 493 */
489void 494void
490GNUNET_SOCKS_set_handshake_destination (struct GNUNET_SOCKS_Handshake *ih, 495GNUNET_SOCKS_set_handshake_destination (struct GNUNET_SOCKS_Handshake *ih,
@@ -529,7 +534,7 @@ GNUNET_SOCKS_set_handshake_destination (struct GNUNET_SOCKS_Handshake *ih,
529 * @param c open unused connection, consumed here. 534 * @param c open unused connection, consumed here.
530 * @return Connection handle that becomes usable when the SOCKS5 handshake completes. 535 * @return Connection handle that becomes usable when the SOCKS5 handshake completes.
531 */ 536 */
532struct GNUNET_CONNECTION_Handle * 537struct GNUNET_CONNECTION_Handle *
533GNUNET_SOCKS_run_handshake(struct GNUNET_SOCKS_Handshake *ih, 538GNUNET_SOCKS_run_handshake(struct GNUNET_SOCKS_Handshake *ih,
534 struct GNUNET_CONNECTION_Handle *c) 539 struct GNUNET_CONNECTION_Handle *c)
535{ 540{
@@ -580,7 +585,7 @@ GNUNET_SOCKS_do_connect (const char *service_name,
580 if (GNUNET_OK != 585 if (GNUNET_OK !=
581 GNUNET_CONFIGURATION_get_value_number (cfg, service_name, "SOCKSPORT", &port0)) 586 GNUNET_CONFIGURATION_get_value_number (cfg, service_name, "SOCKSPORT", &port0))
582 port0 = 9050; 587 port0 = 9050;
583 /* A typical Tor client should usually try port 9150 for the TBB too, but 588 /* A typical Tor client should usually try port 9150 for the TBB too, but
584 * GUNNet can probably assume a system Tor instalation. */ 589 * GUNNet can probably assume a system Tor instalation. */
585 if (GNUNET_OK != 590 if (GNUNET_OK !=
586 GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "SOCKSHOST", &host0)) 591 GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "SOCKSHOST", &host0))
diff --git a/src/util/speedup.c b/src/util/speedup.c
index a42ed7faf..6dce6a490 100644
--- a/src/util/speedup.c
+++ b/src/util/speedup.c
@@ -34,16 +34,17 @@ static struct GNUNET_TIME_Relative interval;
34 34
35static struct GNUNET_TIME_Relative delta; 35static struct GNUNET_TIME_Relative delta;
36 36
37static struct GNUNET_SCHEDULER_Task * speedup_task; 37static struct GNUNET_SCHEDULER_Task *speedup_task;
38 38
39 39
40static void 40static void
41do_speedup (void *cls, 41do_speedup (void *cls)
42 const struct GNUNET_SCHEDULER_TaskContext *tc)
43{ 42{
44 static long long current_offset; 43 static long long current_offset;
44 const struct GNUNET_SCHEDULER_TaskContext *tc;
45 45
46 speedup_task = NULL; 46 speedup_task = NULL;
47 tc = GNUNET_SCHEDULER_get_task_context ();
47 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) 48 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
48 return; 49 return;
49 current_offset += delta.rel_value_us; 50 current_offset += delta.rel_value_us;
diff --git a/src/util/test_client.c b/src/util/test_client.c
index d8bf67ac6..dab985e5f 100644
--- a/src/util/test_client.c
+++ b/src/util/test_client.c
@@ -125,7 +125,7 @@ make_msg (void *cls, size_t size, void *buf)
125 125
126 126
127static void 127static void
128task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 128task (void *cls)
129{ 129{
130 struct sockaddr_in sa; 130 struct sockaddr_in sa;
131 struct sockaddr *sap[2]; 131 struct sockaddr *sap[2];
diff --git a/src/util/test_common_logging_runtime_loglevels.c b/src/util/test_common_logging_runtime_loglevels.c
index 6c33c2da1..21eb3c6c6 100644
--- a/src/util/test_common_logging_runtime_loglevels.c
+++ b/src/util/test_common_logging_runtime_loglevels.c
@@ -58,7 +58,7 @@ runone (void);
58 58
59 59
60static void 60static void
61end_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 61end_task (void *cls)
62{ 62{
63 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending phase %d, ok is %d\n", phase, 63 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending phase %d, ok is %d\n", phase,
64 ok); 64 ok);
@@ -215,7 +215,7 @@ static int bytes;
215 215
216 216
217static void 217static void
218read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 218read_call (void *cls)
219{ 219{
220 const struct GNUNET_DISK_FileHandle *stdout_read_handle = cls; 220 const struct GNUNET_DISK_FileHandle *stdout_read_handle = cls;
221 char level[8]; 221 char level[8];
@@ -425,7 +425,7 @@ runone ()
425 425
426 426
427static void 427static void
428task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 428task (void *cls)
429{ 429{
430 phase = 0; 430 phase = 0;
431 runone (); 431 runone ();
diff --git a/src/util/test_connection.c b/src/util/test_connection.c
index c4987d27d..eaca75c2e 100644
--- a/src/util/test_connection.c
+++ b/src/util/test_connection.c
@@ -98,7 +98,7 @@ receive_check (void *cls, const void *buf, size_t available,
98 98
99 99
100static void 100static void
101run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 101run_accept (void *cls)
102{ 102{
103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test accepts connection\n"); 103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test accepts connection\n");
104 asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls); 104 asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls);
@@ -128,7 +128,7 @@ make_hello (void *cls, size_t size, void *buf)
128 128
129 129
130static void 130static void
131task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 131task (void *cls)
132{ 132{
133 ls = open_listen_socket (); 133 ls = open_listen_socket ();
134 lsock = GNUNET_CONNECTION_create_from_existing (ls); 134 lsock = GNUNET_CONNECTION_create_from_existing (ls);
diff --git a/src/util/test_connection_addressing.c b/src/util/test_connection_addressing.c
index 5d2766f5f..a6345b10a 100644
--- a/src/util/test_connection_addressing.c
+++ b/src/util/test_connection_addressing.c
@@ -102,7 +102,7 @@ receive_check (void *cls, const void *buf, size_t available,
102 102
103 103
104static void 104static void
105run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 105run_accept (void *cls)
106{ 106{
107 void *addr; 107 void *addr;
108 size_t alen; 108 size_t alen;
@@ -142,7 +142,7 @@ make_hello (void *cls, size_t size, void *buf)
142 142
143 143
144static void 144static void
145task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 145task (void *cls)
146{ 146{
147 struct sockaddr_in v4; 147 struct sockaddr_in v4;
148 148
diff --git a/src/util/test_connection_receive_cancel.c b/src/util/test_connection_receive_cancel.c
index 73a041bdf..9ec96d8a6 100644
--- a/src/util/test_connection_receive_cancel.c
+++ b/src/util/test_connection_receive_cancel.c
@@ -79,7 +79,7 @@ dead_receive (void *cls, const void *buf, size_t available,
79 79
80 80
81static void 81static void
82run_accept_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 82run_accept_cancel (void *cls)
83{ 83{
84 asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls); 84 asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls);
85 GNUNET_assert (asock != NULL); 85 GNUNET_assert (asock != NULL);
@@ -92,7 +92,7 @@ run_accept_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
92 92
93 93
94static void 94static void
95receive_cancel_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 95receive_cancel_task (void *cls)
96{ 96{
97 int *ok = cls; 97 int *ok = cls;
98 98
@@ -105,7 +105,7 @@ receive_cancel_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
105 105
106 106
107static void 107static void
108task_receive_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 108task_receive_cancel (void *cls)
109{ 109{
110 ls = open_listen_socket (); 110 ls = open_listen_socket ();
111 lsock = GNUNET_CONNECTION_create_from_existing (ls); 111 lsock = GNUNET_CONNECTION_create_from_existing (ls);
diff --git a/src/util/test_connection_timeout.c b/src/util/test_connection_timeout.c
index 5a649f5b0..e78cec669 100644
--- a/src/util/test_connection_timeout.c
+++ b/src/util/test_connection_timeout.c
@@ -93,7 +93,7 @@ send_kilo (void *cls, size_t size, void *buf)
93 93
94 94
95static void 95static void
96task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 96task_timeout (void *cls)
97{ 97{
98 98
99 ls = open_listen_socket (); 99 ls = open_listen_socket ();
diff --git a/src/util/test_connection_timeout_no_connect.c b/src/util/test_connection_timeout_no_connect.c
index 1e3230d2f..ebcd4b71e 100644
--- a/src/util/test_connection_timeout_no_connect.c
+++ b/src/util/test_connection_timeout_no_connect.c
@@ -44,7 +44,7 @@ handle_timeout (void *cls, size_t size, void *buf)
44 44
45 45
46static void 46static void
47task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 47task_timeout (void *cls)
48{ 48{
49 csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); 49 csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT);
50 GNUNET_assert (csock != NULL); 50 GNUNET_assert (csock != NULL);
diff --git a/src/util/test_connection_transmit_cancel.c b/src/util/test_connection_transmit_cancel.c
index 8d016068c..9ef0720ed 100644
--- a/src/util/test_connection_transmit_cancel.c
+++ b/src/util/test_connection_transmit_cancel.c
@@ -38,7 +38,7 @@ not_run (void *cls, size_t size, void *buf)
38 38
39 39
40static void 40static void
41task_transmit_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 41task_transmit_cancel (void *cls)
42{ 42{
43 int *ok = cls; 43 int *ok = cls;
44 struct GNUNET_CONNECTION_TransmitHandle *th; 44 struct GNUNET_CONNECTION_TransmitHandle *th;
diff --git a/src/util/test_crypto_hash.c b/src/util/test_crypto_hash.c
index fa0013264..731205841 100644
--- a/src/util/test_crypto_hash.c
+++ b/src/util/test_crypto_hash.c
@@ -114,7 +114,7 @@ finished_task (void *cls, const struct GNUNET_HashCode * res)
114 114
115 115
116static void 116static void
117file_hasher (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 117file_hasher (void *cls)
118{ 118{
119 GNUNET_assert (NULL != 119 GNUNET_assert (NULL !=
120 GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_DEFAULT, 120 GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
diff --git a/src/util/test_disk.c b/src/util/test_disk.c
index 560b6710e..86b96e16c 100644
--- a/src/util/test_disk.c
+++ b/src/util/test_disk.c
@@ -141,12 +141,13 @@ iter_callback (void *cls, struct GNUNET_DISK_DirectoryIterator *di,
141} 141}
142 142
143static void 143static void
144iter_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 144iter_task (void *cls)
145{ 145{
146 GNUNET_DISK_directory_iterator_start (GNUNET_SCHEDULER_PRIORITY_DEFAULT, 146 GNUNET_DISK_directory_iterator_start (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
147 "test", &iter_callback, cls); 147 "test", &iter_callback, cls);
148} 148}
149 149
150
150static int 151static int
151testDirIter () 152testDirIter ()
152{ 153{
diff --git a/src/util/test_mq_client.c b/src/util/test_mq_client.c
index 0d2f3befe..f894c3912 100644
--- a/src/util/test_mq_client.c
+++ b/src/util/test_mq_client.c
@@ -62,7 +62,7 @@ recv_cb (void *cls, struct GNUNET_SERVER_Client *argclient,
62 62
63 63
64static void 64static void
65clean_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 65clean_up (void *cls)
66{ 66{
67 GNUNET_SERVER_destroy (server); 67 GNUNET_SERVER_destroy (server);
68 server = NULL; 68 server = NULL;
@@ -134,7 +134,7 @@ test_mq (struct GNUNET_CLIENT_Connection *client)
134 134
135 135
136static void 136static void
137task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 137task (void *cls)
138{ 138{
139 struct sockaddr_in sa; 139 struct sockaddr_in sa;
140 struct sockaddr *sap[2]; 140 struct sockaddr *sap[2];
@@ -181,4 +181,3 @@ main (int argc, char *argv[])
181 GNUNET_assert (GNUNET_YES == notify); 181 GNUNET_assert (GNUNET_YES == notify);
182 return ok; 182 return ok;
183} 183}
184
diff --git a/src/util/test_os_start_process.c b/src/util/test_os_start_process.c
index 3823beb3d..c617917cc 100644
--- a/src/util/test_os_start_process.c
+++ b/src/util/test_os_start_process.c
@@ -58,7 +58,7 @@ struct read_context
58struct read_context rc; 58struct read_context rc;
59 59
60static void 60static void
61end_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 61end_task (void *cls)
62{ 62{
63 if (0 != GNUNET_OS_process_kill (proc, GNUNET_TERM_SIG)) 63 if (0 != GNUNET_OS_process_kill (proc, GNUNET_TERM_SIG))
64 { 64 {
@@ -73,7 +73,7 @@ end_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
73 73
74 74
75static void 75static void
76read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 76read_call (void *cls)
77{ 77{
78 int bytes; 78 int bytes;
79 79
@@ -110,7 +110,7 @@ read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
110 110
111 111
112static void 112static void
113run_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 113run_task (void *cls)
114{ 114{
115 char *fn; 115 char *fn;
116 const struct GNUNET_DISK_FileHandle *stdout_read_handle; 116 const struct GNUNET_DISK_FileHandle *stdout_read_handle;
diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c
index 01d93febd..a246d75c5 100644
--- a/src/util/test_scheduler.c
+++ b/src/util/test_scheduler.c
@@ -31,7 +31,7 @@ static const struct GNUNET_DISK_FileHandle *fds[2];
31 31
32 32
33static void 33static void
34task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 34task2 (void *cls)
35{ 35{
36 int *ok = cls; 36 int *ok = cls;
37 37
@@ -44,7 +44,7 @@ task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
44 44
45 45
46static void 46static void
47task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 47task3 (void *cls)
48{ 48{
49 int *ok = cls; 49 int *ok = cls;
50 50
@@ -54,11 +54,13 @@ task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
54 54
55 55
56static void 56static void
57taskWrt (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 57taskWrt (void *cls)
58{ 58{
59 static char c; 59 static char c;
60 int *ok = cls; 60 int *ok = cls;
61 const struct GNUNET_SCHEDULER_TaskContext *tc;
61 62
63 tc = GNUNET_SCHEDULER_get_task_context ();
62 GNUNET_assert (6 == *ok); 64 GNUNET_assert (6 == *ok);
63 GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->write_ready, fds[1])); 65 GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->write_ready, fds[1]));
64 (*ok) = 7; 66 (*ok) = 7;
@@ -67,14 +69,14 @@ taskWrt (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
67 69
68 70
69static void 71static void
70taskNeverRun (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 72taskNeverRun (void *cls)
71{ 73{
72 GNUNET_assert (0); 74 GNUNET_assert (0);
73} 75}
74 76
75 77
76static void 78static void
77taskLast (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 79taskLast (void *cls)
78{ 80{
79 int *ok = cls; 81 int *ok = cls;
80 82
@@ -85,11 +87,13 @@ taskLast (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
85 87
86 88
87static void 89static void
88taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 90taskRd (void *cls)
89{ 91{
90 static char c; 92 static char c;
91 int *ok = cls; 93 int *ok = cls;
94 const struct GNUNET_SCHEDULER_TaskContext *tc;
92 95
96 tc = GNUNET_SCHEDULER_get_task_context ();
93 GNUNET_assert (7 == *ok); 97 GNUNET_assert (7 == *ok);
94 GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); 98 GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0]));
95 GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); 99 GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1));
@@ -101,7 +105,7 @@ taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
101 105
102 106
103static void 107static void
104task4 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 108task4 (void *cls)
105{ 109{
106 int *ok = cls; 110 int *ok = cls;
107 111
@@ -119,7 +123,7 @@ task4 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
119 123
120 124
121static void 125static void
122task1 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 126task1 (void *cls)
123{ 127{
124 int *ok = cls; 128 int *ok = cls;
125 129
@@ -148,7 +152,7 @@ check ()
148 152
149 153
150static void 154static void
151taskShutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 155taskShutdown (void *cls)
152{ 156{
153 int *ok = cls; 157 int *ok = cls;
154 158
@@ -176,7 +180,7 @@ checkShutdown ()
176 180
177#ifndef MINGW 181#ifndef MINGW
178static void 182static void
179taskSig (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 183taskSig (void *cls)
180{ 184{
181 int *ok = cls; 185 int *ok = cls;
182 186
@@ -204,7 +208,7 @@ checkSignal ()
204 208
205 209
206static void 210static void
207taskCancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 211taskCancel (void *cls)
208{ 212{
209 int *ok = cls; 213 int *ok = cls;
210 214
diff --git a/src/util/test_scheduler_delay.c b/src/util/test_scheduler_delay.c
index c3821a173..c55f28e9b 100644
--- a/src/util/test_scheduler_delay.c
+++ b/src/util/test_scheduler_delay.c
@@ -41,11 +41,9 @@ static unsigned long long cumDelta;
41 * Signature of the main function of a task. 41 * Signature of the main function of a task.
42 * 42 *
43 * @param cls closure 43 * @param cls closure
44 * @param tc context
45 */ 44 */
46static void 45static void
47test_task (void *cls, 46test_task (void *cls)
48 const struct GNUNET_SCHEDULER_TaskContext *tc)
49{ 47{
50 struct GNUNET_TIME_Absolute now; 48 struct GNUNET_TIME_Absolute now;
51 49
diff --git a/src/util/test_server.c b/src/util/test_server.c
index fdf298128..189c13e18 100644
--- a/src/util/test_server.c
+++ b/src/util/test_server.c
@@ -74,11 +74,9 @@ static int ok;
74 * Final task invoked to clean up. 74 * Final task invoked to clean up.
75 * 75 *
76 * @param cls NULL 76 * @param cls NULL
77 * @param tc scheduler context
78 */ 77 */
79static void 78static void
80finish_up (void *cls, 79finish_up (void *cls)
81 const struct GNUNET_SCHEDULER_TaskContext *tc)
82{ 80{
83 GNUNET_assert (7 == ok); 81 GNUNET_assert (7 == ok);
84 ok = 0; 82 ok = 0;
@@ -262,11 +260,9 @@ static struct GNUNET_SERVER_MessageHandler handlers[] = {
262 * server. 260 * server.
263 * 261 *
264 * @param cls NULL 262 * @param cls NULL
265 * @param tc scheduler context
266 */ 263 */
267static void 264static void
268task (void *cls, 265task (void *cls)
269 const struct GNUNET_SCHEDULER_TaskContext *tc)
270{ 266{
271 struct sockaddr_in sa; 267 struct sockaddr_in sa;
272 struct sockaddr *sap[2]; 268 struct sockaddr *sap[2];
diff --git a/src/util/test_server_disconnect.c b/src/util/test_server_disconnect.c
index 4a6970fc3..21abf92bb 100644
--- a/src/util/test_server_disconnect.c
+++ b/src/util/test_server_disconnect.c
@@ -41,7 +41,7 @@ static int ok;
41 41
42 42
43static void 43static void
44finish_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 44finish_up (void *cls)
45{ 45{
46 GNUNET_assert (ok == 5); 46 GNUNET_assert (ok == 5);
47 ok = 0; 47 ok = 0;
@@ -52,9 +52,10 @@ finish_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
52 52
53 53
54static void 54static void
55notify_disconnect (void *cls, struct GNUNET_SERVER_Client *clientarg) 55notify_disconnect (void *cls,
56 struct GNUNET_SERVER_Client *clientarg)
56{ 57{
57 if (clientarg == NULL) 58 if (NULL == clientarg)
58 return; 59 return;
59 GNUNET_assert (ok == 4); 60 GNUNET_assert (ok == 4);
60 ok = 5; 61 ok = 5;
@@ -63,7 +64,7 @@ notify_disconnect (void *cls, struct GNUNET_SERVER_Client *clientarg)
63 64
64 65
65static void 66static void
66server_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 67server_disconnect (void *cls)
67{ 68{
68 struct GNUNET_SERVER_Client *argclient = cls; 69 struct GNUNET_SERVER_Client *argclient = cls;
69 70
@@ -110,7 +111,7 @@ transmit_initial_message (void *cls, size_t size, void *buf)
110 111
111 112
112static void 113static void
113task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 114task (void *cls)
114{ 115{
115 struct sockaddr_in sa; 116 struct sockaddr_in sa;
116 struct sockaddr *sap[2]; 117 struct sockaddr *sap[2];
diff --git a/src/util/test_server_with_client.c b/src/util/test_server_with_client.c
index 07bc88783..8a8f65474 100644
--- a/src/util/test_server_with_client.c
+++ b/src/util/test_server_with_client.c
@@ -40,7 +40,7 @@ static struct GNUNET_CONFIGURATION_Handle *cfg;
40static int ok; 40static int ok;
41 41
42static void 42static void
43send_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 43send_done (void *cls)
44{ 44{
45 struct GNUNET_SERVER_Client *argclient = cls; 45 struct GNUNET_SERVER_Client *argclient = cls;
46 46
@@ -94,7 +94,7 @@ recv_cb (void *cls, struct GNUNET_SERVER_Client *argclient,
94 94
95 95
96static void 96static void
97clean_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 97clean_up (void *cls)
98{ 98{
99 GNUNET_SERVER_destroy (server); 99 GNUNET_SERVER_destroy (server);
100 server = NULL; 100 server = NULL;
@@ -146,7 +146,7 @@ static struct GNUNET_SERVER_MessageHandler handlers[] = {
146 146
147 147
148static void 148static void
149task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 149task (void *cls)
150{ 150{
151 struct sockaddr_in sa; 151 struct sockaddr_in sa;
152 struct sockaddr *sap[2]; 152 struct sockaddr *sap[2];
diff --git a/src/util/test_server_with_client_unix.c b/src/util/test_server_with_client_unix.c
index 1d6f5dbed..ec84b08f8 100644
--- a/src/util/test_server_with_client_unix.c
+++ b/src/util/test_server_with_client_unix.c
@@ -39,7 +39,7 @@ static int ok;
39 39
40 40
41static void 41static void
42send_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 42send_done (void *cls)
43{ 43{
44 struct GNUNET_SERVER_Client *argclient = cls; 44 struct GNUNET_SERVER_Client *argclient = cls;
45 45
@@ -74,7 +74,7 @@ recv_cb (void *cls, struct GNUNET_SERVER_Client *argclient,
74 74
75 75
76static void 76static void
77clean_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 77clean_up (void *cls)
78{ 78{
79 GNUNET_SERVER_destroy (server); 79 GNUNET_SERVER_destroy (server);
80 server = NULL; 80 server = NULL;
@@ -126,7 +126,7 @@ static struct GNUNET_SERVER_MessageHandler handlers[] = {
126 126
127 127
128static void 128static void
129task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 129task (void *cls)
130{ 130{
131 struct sockaddr_un un; 131 struct sockaddr_un un;
132 const char *unixpath = "/tmp/testsock"; 132 const char *unixpath = "/tmp/testsock";
diff --git a/src/util/test_service.c b/src/util/test_service.c
index 88f99f95a..efc765438 100644
--- a/src/util/test_service.c
+++ b/src/util/test_service.c
@@ -41,7 +41,7 @@ static struct GNUNET_CLIENT_Connection *client;
41 41
42 42
43static void 43static void
44do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 44do_stop (void *cls)
45{ 45{
46 if (NULL != client) 46 if (NULL != client)
47 { 47 {
diff --git a/src/util/test_socks.c b/src/util/test_socks.c
index bb7d0031a..7f1140720 100644
--- a/src/util/test_socks.c
+++ b/src/util/test_socks.c
@@ -126,7 +126,7 @@ make_msg (void *cls, size_t size, void *buf)
126 126
127 127
128static void 128static void
129task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 129task (void *cls)
130{ 130{
131 struct sockaddr_in sa; 131 struct sockaddr_in sa;
132 struct sockaddr *sap[2]; 132 struct sockaddr *sap[2];
diff --git a/src/util/test_speedup.c b/src/util/test_speedup.c
index 3c4a9bfdc..5d46e3127 100644
--- a/src/util/test_speedup.c
+++ b/src/util/test_speedup.c
@@ -47,7 +47,7 @@ static unsigned int cycles;
47 * @param tc scheduler context, unused 47 * @param tc scheduler context, unused
48 */ 48 */
49static void 49static void
50run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 50run (void *cls)
51{ 51{
52 cycles++; 52 cycles++;
53 fprintf (stderr, "..%u", cycles); 53 fprintf (stderr, "..%u", cycles);