aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-cadet-profiler.c
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/cadet/gnunet-cadet-profiler.c
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/cadet/gnunet-cadet-profiler.c')
-rw-r--r--src/cadet/gnunet-cadet-profiler.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/cadet/gnunet-cadet-profiler.c b/src/cadet/gnunet-cadet-profiler.c
index bda844b13..ffa993f8e 100644
--- a/src/cadet/gnunet-cadet-profiler.c
+++ b/src/cadet/gnunet-cadet-profiler.c
@@ -249,10 +249,9 @@ static int test_finished;
249 * on callback funtion ch. 249 * on callback funtion ch.
250 * 250 *
251 * @param cls Closure (unsued). 251 * @param cls Closure (unsued).
252 * @param tc Task Context.
253 */ 252 */
254static void 253static void
255start_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 254start_test (void *cls);
256 255
257 256
258/** 257/**
@@ -314,10 +313,9 @@ show_end_data (void)
314 * Shut down peergroup, clean up. 313 * Shut down peergroup, clean up.
315 * 314 *
316 * @param cls Closure (unused). 315 * @param cls Closure (unused).
317 * @param tc Task Context.
318 */ 316 */
319static void 317static void
320shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 318shutdown_task (void *cls)
321{ 319{
322 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Ending test.\n"); 320 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Ending test.\n");
323 shutdown_handle = NULL; 321 shutdown_handle = NULL;
@@ -328,10 +326,9 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
328 * Disconnect from cadet services af all peers, call shutdown. 326 * Disconnect from cadet services af all peers, call shutdown.
329 * 327 *
330 * @param cls Closure (unused). 328 * @param cls Closure (unused).
331 * @param tc Task Context.
332 */ 329 */
333static void 330static void
334disconnect_cadet_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 331disconnect_cadet_peers (void *cls)
335{ 332{
336 long line = (long) cls; 333 long line = (long) cls;
337 unsigned int i; 334 unsigned int i;
@@ -443,11 +440,13 @@ stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer,
443 * Task check that keepalives were sent and received. 440 * Task check that keepalives were sent and received.
444 * 441 *
445 * @param cls Closure (NULL). 442 * @param cls Closure (NULL).
446 * @param tc Task Context.
447 */ 443 */
448static void 444static void
449collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 445collect_stats (void *cls)
450{ 446{
447 const struct GNUNET_SCHEDULER_TaskContext *tc;
448
449 tc = GNUNET_SCHEDULER_get_task_context ();
451 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) 450 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
452 return; 451 return;
453 452
@@ -462,11 +461,13 @@ collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
462 * @brief Finish profiler normally. Signal finish and start collecting stats. 461 * @brief Finish profiler normally. Signal finish and start collecting stats.
463 * 462 *
464 * @param cls Closure (unused). 463 * @param cls Closure (unused).
465 * @param tc Task context.
466 */ 464 */
467static void 465static void
468finish_profiler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 466finish_profiler (void *cls)
469{ 467{
468 const struct GNUNET_SCHEDULER_TaskContext *tc;
469
470 tc = GNUNET_SCHEDULER_get_task_context ();
470 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) 471 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
471 return; 472 return;
472 473
@@ -542,11 +543,13 @@ adjust_running_peers (unsigned int target)
542 * @brief Move to next round. 543 * @brief Move to next round.
543 * 544 *
544 * @param cls Closure (round #). 545 * @param cls Closure (round #).
545 * @param tc Task context.
546 */ 546 */
547static void 547static void
548next_rnd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 548next_rnd (void *cls)
549{ 549{
550 const struct GNUNET_SCHEDULER_TaskContext *tc;
551
552 tc = GNUNET_SCHEDULER_get_task_context ();
550 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) 553 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
551 return; 554 return;
552 555
@@ -608,15 +611,15 @@ tmt_rdy_pong (void *cls, size_t size, void *buf)
608 * @brief Send a ping to destination 611 * @brief Send a ping to destination
609 * 612 *
610 * @param cls Closure (peer). 613 * @param cls Closure (peer).
611 * @param tc Task context.
612 */ 614 */
613static void 615static void
614ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 616ping (void *cls)
615{ 617{
616 struct CadetPeer *peer = (struct CadetPeer *) cls; 618 struct CadetPeer *peer = cls;
619 const struct GNUNET_SCHEDULER_TaskContext *tc;
617 620
618 peer->ping_task = NULL; 621 peer->ping_task = NULL;
619 622 tc = GNUNET_SCHEDULER_get_task_context ();
620 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) 623 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)
621 || GNUNET_YES == test_finished) 624 || GNUNET_YES == test_finished)
622 return; 625 return;
@@ -865,15 +868,16 @@ select_random_peer (struct CadetPeer *peer)
865 * on callback funtion ch. 868 * on callback funtion ch.
866 * 869 *
867 * @param cls Closure (unsued). 870 * @param cls Closure (unsued).
868 * @param tc Task Context.
869 */ 871 */
870static void 872static void
871start_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 873start_test (void *cls)
872{ 874{
873 enum GNUNET_CADET_ChannelOption flags; 875 enum GNUNET_CADET_ChannelOption flags;
874 unsigned long i; 876 unsigned long i;
877 const struct GNUNET_SCHEDULER_TaskContext *tc;
875 878
876 test_task = NULL; 879 test_task = NULL;
880 tc = GNUNET_SCHEDULER_get_task_context ();
877 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) 881 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
878 return; 882 return;
879 883
@@ -1089,4 +1093,3 @@ main (int argc, char *argv[])
1089} 1093}
1090 1094
1091/* end of gnunet-cadet-profiler.c */ 1095/* end of gnunet-cadet-profiler.c */
1092