diff options
author | Julius Bünger <buenger@mytum.de> | 2018-07-11 16:36:25 +0200 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2018-07-11 16:36:25 +0200 |
commit | efc0c09784d55ea347e6208dece55593241f2346 (patch) | |
tree | a31eed12e42ef196b7938c686f03274bca5c1f43 /src/rps/gnunet-rps-profiler.c | |
parent | a5c75acc95be6f1b02f5eb3fb039f7c7fa7e4877 (diff) | |
download | gnunet-efc0c09784d55ea347e6208dece55593241f2346.tar.gz gnunet-efc0c09784d55ea347e6208dece55593241f2346.zip |
rps profiler: reorganise shutdown
Diffstat (limited to 'src/rps/gnunet-rps-profiler.c')
-rw-r--r-- | src/rps/gnunet-rps-profiler.c | 70 |
1 files changed, 48 insertions, 22 deletions
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c index 4ebd745e8..a1728cccf 100644 --- a/src/rps/gnunet-rps-profiler.c +++ b/src/rps/gnunet-rps-profiler.c | |||
@@ -497,15 +497,16 @@ static unsigned int view_sizes; | |||
497 | static int ok; | 497 | static int ok; |
498 | 498 | ||
499 | /** | 499 | /** |
500 | * Identifier for the churn task that runs periodically | 500 | * Identifier for the task that runs after the test to collect results |
501 | */ | 501 | */ |
502 | static struct GNUNET_SCHEDULER_Task *post_test_task; | 502 | static struct GNUNET_SCHEDULER_Task *post_test_task; |
503 | 503 | ||
504 | /** | 504 | /** |
505 | * Identifier for the churn task that runs periodically | 505 | * Identifier for the shutdown task |
506 | */ | 506 | */ |
507 | static struct GNUNET_SCHEDULER_Task *shutdown_task; | 507 | static struct GNUNET_SCHEDULER_Task *shutdown_task; |
508 | 508 | ||
509 | |||
509 | /** | 510 | /** |
510 | * Identifier for the churn task that runs periodically | 511 | * Identifier for the churn task that runs periodically |
511 | */ | 512 | */ |
@@ -969,7 +970,12 @@ shutdown_op (void *cls) | |||
969 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 970 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
970 | "Shutdown task scheduled, going down.\n"); | 971 | "Shutdown task scheduled, going down.\n"); |
971 | in_shutdown = GNUNET_YES; | 972 | in_shutdown = GNUNET_YES; |
972 | shutdown_task = NULL; | 973 | |
974 | if (NULL != shutdown_task) | ||
975 | { | ||
976 | GNUNET_SCHEDULER_cancel (shutdown_task); | ||
977 | shutdown_task = NULL; | ||
978 | } | ||
973 | if (NULL != post_test_task) | 979 | if (NULL != post_test_task) |
974 | { | 980 | { |
975 | GNUNET_SCHEDULER_cancel (post_test_task); | 981 | GNUNET_SCHEDULER_cancel (post_test_task); |
@@ -994,6 +1000,14 @@ shutdown_op (void *cls) | |||
994 | { | 1000 | { |
995 | clean_peer (i); | 1001 | clean_peer (i); |
996 | } | 1002 | } |
1003 | } | ||
1004 | |||
1005 | static void | ||
1006 | trigger_shutdown (void *cls) | ||
1007 | { | ||
1008 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1009 | "Shutdown was triggerd by timeout, going down.\n"); | ||
1010 | shutdown_task = NULL; | ||
997 | GNUNET_SCHEDULER_shutdown (); | 1011 | GNUNET_SCHEDULER_shutdown (); |
998 | } | 1012 | } |
999 | 1013 | ||
@@ -1009,7 +1023,7 @@ post_test_op (void *cls) | |||
1009 | post_test_task = NULL; | 1023 | post_test_task = NULL; |
1010 | post_test = GNUNET_YES; | 1024 | post_test = GNUNET_YES; |
1011 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1025 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1012 | "Post test task scheduled, going down.\n"); | 1026 | "Post test task scheduled.\n"); |
1013 | if (NULL != churn_task) | 1027 | if (NULL != churn_task) |
1014 | { | 1028 | { |
1015 | GNUNET_SCHEDULER_cancel (churn_task); | 1029 | GNUNET_SCHEDULER_cancel (churn_task); |
@@ -1033,7 +1047,8 @@ post_test_op (void *cls) | |||
1033 | GNUNET_YES == check_statistics_collect_completed()) | 1047 | GNUNET_YES == check_statistics_collect_completed()) |
1034 | { | 1048 | { |
1035 | GNUNET_SCHEDULER_cancel (shutdown_task); | 1049 | GNUNET_SCHEDULER_cancel (shutdown_task); |
1036 | shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL); | 1050 | shutdown_task = NULL; |
1051 | GNUNET_SCHEDULER_shutdown (); | ||
1037 | } | 1052 | } |
1038 | } | 1053 | } |
1039 | 1054 | ||
@@ -1142,7 +1157,7 @@ rps_connect_complete_cb (void *cls, | |||
1142 | "Failed to connect to RPS service: %s\n", | 1157 | "Failed to connect to RPS service: %s\n", |
1143 | emsg); | 1158 | emsg); |
1144 | ok = 1; | 1159 | ok = 1; |
1145 | shutdown_op (NULL); | 1160 | GNUNET_SCHEDULER_shutdown (); |
1146 | return; | 1161 | return; |
1147 | } | 1162 | } |
1148 | 1163 | ||
@@ -1316,14 +1331,15 @@ default_reply_handle (void *cls, | |||
1316 | rps_peer->num_recv_ids++; | 1331 | rps_peer->num_recv_ids++; |
1317 | } | 1332 | } |
1318 | 1333 | ||
1319 | if (0 == evaluate () && HAVE_QUICK_QUIT == cur_test_run.have_quick_quit) | 1334 | if (GNUNET_YES != post_test) return; |
1335 | if (HAVE_QUICK_QUIT != cur_test_run.have_quick_quit) return; | ||
1336 | if (0 == evaluate()) | ||
1320 | { | 1337 | { |
1321 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1338 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1322 | "Test succeeded before end of duration\n"); | 1339 | "Test succeeded before end of duration\n"); |
1323 | GNUNET_assert (NULL != post_test_task); | 1340 | if (NULL != post_test_task) GNUNET_SCHEDULER_cancel (post_test_task); |
1324 | GNUNET_SCHEDULER_cancel (post_test_task); | ||
1325 | post_test_task = GNUNET_SCHEDULER_add_now (&post_test_op, NULL); | 1341 | post_test_task = GNUNET_SCHEDULER_add_now (&post_test_op, NULL); |
1326 | GNUNET_assert (NULL!= post_test_task); | 1342 | GNUNET_assert (NULL != post_test_task); |
1327 | } | 1343 | } |
1328 | } | 1344 | } |
1329 | 1345 | ||
@@ -1548,7 +1564,7 @@ churn_cb (void *cls, | |||
1548 | if (NULL != emsg) | 1564 | if (NULL != emsg) |
1549 | { | 1565 | { |
1550 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start/stop RPS at a peer\n"); | 1566 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start/stop RPS at a peer\n"); |
1551 | shutdown_op (NULL); | 1567 | GNUNET_SCHEDULER_shutdown (); |
1552 | return; | 1568 | return; |
1553 | } | 1569 | } |
1554 | GNUNET_assert (0 != entry->delta); | 1570 | GNUNET_assert (0 != entry->delta); |
@@ -2400,7 +2416,7 @@ post_test_shutdown_ready_cb (void *cls, | |||
2400 | GNUNET_free (stat_cls); | 2416 | GNUNET_free (stat_cls); |
2401 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2417 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2402 | "Shutting down\n"); | 2418 | "Shutting down\n"); |
2403 | shutdown_op (NULL); | 2419 | GNUNET_SCHEDULER_shutdown (); |
2404 | } else { | 2420 | } else { |
2405 | GNUNET_free (stat_cls); | 2421 | GNUNET_free (stat_cls); |
2406 | } | 2422 | } |
@@ -2637,7 +2653,10 @@ test_run (void *cls, | |||
2637 | GNUNET_SCHEDULER_cancel (churn_task); | 2653 | GNUNET_SCHEDULER_cancel (churn_task); |
2638 | post_test_task = GNUNET_SCHEDULER_add_delayed (duration, &post_test_op, NULL); | 2654 | post_test_task = GNUNET_SCHEDULER_add_delayed (duration, &post_test_op, NULL); |
2639 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "timeout for shutdown is %lu\n", timeout.rel_value_us/1000000); | 2655 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "timeout for shutdown is %lu\n", timeout.rel_value_us/1000000); |
2640 | shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); | 2656 | shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, |
2657 | &trigger_shutdown, | ||
2658 | NULL); | ||
2659 | GNUNET_SCHEDULER_add_shutdown (shutdown_op, NULL); | ||
2641 | } | 2660 | } |
2642 | 2661 | ||
2643 | 2662 | ||
@@ -2701,26 +2720,33 @@ run (void *cls, | |||
2701 | if (0 == timeout.rel_value_us) | 2720 | if (0 == timeout.rel_value_us) |
2702 | { | 2721 | { |
2703 | duration = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90); | 2722 | duration = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90); |
2704 | timeout = GNUNET_TIME_relative_multiply (duration, | 2723 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
2705 | 1.2 + (0.01 * num_peers)); | 2724 | (90 * 1.2) + |
2725 | (0.01 * num_peers)); | ||
2706 | } | 2726 | } |
2707 | else | 2727 | else |
2708 | { | 2728 | { |
2709 | duration = GNUNET_TIME_relative_multiply (timeout, 0.75 ); | 2729 | duration = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
2730 | (timeout.rel_value_us/1000000) | ||
2731 | * 0.75); | ||
2710 | } | 2732 | } |
2711 | } | 2733 | } |
2712 | else | 2734 | else |
2713 | { | 2735 | { |
2714 | if (0 == timeout.rel_value_us) | 2736 | if (0 == timeout.rel_value_us) |
2715 | { | 2737 | { |
2716 | timeout = GNUNET_TIME_relative_multiply (duration, | 2738 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
2717 | 1.2 + (0.01 * num_peers)); | 2739 | ((duration.rel_value_us/1000000) |
2718 | } | 2740 | * 1.2) + (0.01 * num_peers)); |
2719 | else | ||
2720 | { | ||
2721 | GNUNET_assert (duration.rel_value_us <= timeout.rel_value_us); | ||
2722 | } | 2741 | } |
2723 | } | 2742 | } |
2743 | GNUNET_assert (duration.rel_value_us < timeout.rel_value_us); | ||
2744 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2745 | "duration is %lus\n", | ||
2746 | duration.rel_value_us/1000000); | ||
2747 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2748 | "timeout is %lus\n", | ||
2749 | timeout.rel_value_us/1000000); | ||
2724 | 2750 | ||
2725 | /* Compute number of bits for representing largest peer id */ | 2751 | /* Compute number of bits for representing largest peer id */ |
2726 | for (bits_needed = 1; (1 << bits_needed) < num_peers; bits_needed++) | 2752 | for (bits_needed = 1; (1 << bits_needed) < num_peers; bits_needed++) |