diff options
author | ng0 <ng0@n0.is> | 2018-01-08 15:25:23 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2018-01-08 15:25:23 +0000 |
commit | 016d2783de2414bfa98e1c29fc8d15d893bbc064 (patch) | |
tree | 7808848ba4b1b98ca335aedf46f04968af4ee2e7 /src/rps/test_rps.c | |
parent | 3e2c2d6c40845d53b2809ec4a224e6d51eea5d73 (diff) | |
parent | d07dddc7d62538c0e087c2a938051cc731b4388a (diff) | |
download | gnunet-016d2783de2414bfa98e1c29fc8d15d893bbc064.tar.gz gnunet-016d2783de2414bfa98e1c29fc8d15d893bbc064.zip |
Merge branch 'master' of gnunet.org:gnunet
Diffstat (limited to 'src/rps/test_rps.c')
-rw-r--r-- | src/rps/test_rps.c | 209 |
1 files changed, 181 insertions, 28 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index 0114a19fe..4d6f1bfd1 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -62,6 +62,19 @@ static unsigned int mal_type = 0; | |||
62 | */ | 62 | */ |
63 | static struct GNUNET_TESTBED_Peer **testbed_peers; | 63 | static struct GNUNET_TESTBED_Peer **testbed_peers; |
64 | 64 | ||
65 | /** | ||
66 | * @brief Indicates whether peer should go off- or online | ||
67 | */ | ||
68 | enum PEER_ONLINE_DELTA { | ||
69 | /** | ||
70 | * @brief Indicates peer going online | ||
71 | */ | ||
72 | PEER_GO_ONLINE = 1, | ||
73 | /** | ||
74 | * @brief Indicates peer going offline | ||
75 | */ | ||
76 | PEER_GO_OFFLINE = -1, | ||
77 | }; | ||
65 | 78 | ||
66 | /** | 79 | /** |
67 | * Operation map entry | 80 | * Operation map entry |
@@ -84,10 +97,10 @@ struct OpListEntry | |||
84 | struct GNUNET_TESTBED_Operation *op; | 97 | struct GNUNET_TESTBED_Operation *op; |
85 | 98 | ||
86 | /** | 99 | /** |
87 | * Depending on whether we start or stop NSE service at the peer set this to 1 | 100 | * Depending on whether we start or stop RPS service at the peer, set this to |
88 | * or -1 | 101 | * #PEER_GO_ONLINE (1) or #PEER_GO_OFFLINE (-1) |
89 | */ | 102 | */ |
90 | int delta; | 103 | enum PEER_ONLINE_DELTA delta; |
91 | 104 | ||
92 | /** | 105 | /** |
93 | * Index of the regarding peer | 106 | * Index of the regarding peer |
@@ -188,7 +201,7 @@ struct RPSPeer | |||
188 | int online; | 201 | int online; |
189 | 202 | ||
190 | /** | 203 | /** |
191 | * Number of Peer IDs to request | 204 | * Number of Peer IDs to request during the whole test |
192 | */ | 205 | */ |
193 | unsigned int num_ids_to_request; | 206 | unsigned int num_ids_to_request; |
194 | 207 | ||
@@ -218,6 +231,11 @@ struct RPSPeer | |||
218 | * Number of received PeerIDs | 231 | * Number of received PeerIDs |
219 | */ | 232 | */ |
220 | unsigned int num_recv_ids; | 233 | unsigned int num_recv_ids; |
234 | |||
235 | /** | ||
236 | * Pending operation on that peer | ||
237 | */ | ||
238 | const struct OpListEntry *entry_op_manage; | ||
221 | }; | 239 | }; |
222 | 240 | ||
223 | 241 | ||
@@ -259,6 +277,11 @@ static int ok; | |||
259 | /** | 277 | /** |
260 | * Identifier for the churn task that runs periodically | 278 | * Identifier for the churn task that runs periodically |
261 | */ | 279 | */ |
280 | static struct GNUNET_SCHEDULER_Task *shutdown_task; | ||
281 | |||
282 | /** | ||
283 | * Identifier for the churn task that runs periodically | ||
284 | */ | ||
262 | static struct GNUNET_SCHEDULER_Task *churn_task; | 285 | static struct GNUNET_SCHEDULER_Task *churn_task; |
263 | 286 | ||
264 | /** | 287 | /** |
@@ -267,13 +290,21 @@ static struct GNUNET_SCHEDULER_Task *churn_task; | |||
267 | typedef void (*InitPeer) (struct RPSPeer *rps_peer); | 290 | typedef void (*InitPeer) (struct RPSPeer *rps_peer); |
268 | 291 | ||
269 | /** | 292 | /** |
270 | * Called directly after connecting to the service | 293 | * @brief Called directly after connecting to the service |
294 | * | ||
295 | * @param rps_peer Specific peer the function is called on | ||
296 | * @param h the handle to the rps service | ||
271 | */ | 297 | */ |
272 | typedef void (*PreTest) (void *cls, struct GNUNET_RPS_Handle *h); | 298 | typedef void (*PreTest) (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h); |
273 | 299 | ||
274 | /** | 300 | /** |
301 | * @brief Executes functions to test the api/service for a given peer | ||
302 | * | ||
275 | * Called from within #rps_connect_complete_cb () | 303 | * Called from within #rps_connect_complete_cb () |
276 | * Executes functions to test the api/service | 304 | * Implemented by #churn_test_cb, #profiler_cb, #mal_cb, #single_req_cb, |
305 | * #delay_req_cb, #seed_big_cb, #single_peer_seed_cb, #seed_cb, #req_cancel_cb | ||
306 | * | ||
307 | * @param rps_peer the peer the task runs on | ||
277 | */ | 308 | */ |
278 | typedef void (*MainTest) (struct RPSPeer *rps_peer); | 309 | typedef void (*MainTest) (struct RPSPeer *rps_peer); |
279 | 310 | ||
@@ -306,7 +337,7 @@ struct SingleTestRun | |||
306 | char *name; | 337 | char *name; |
307 | 338 | ||
308 | /** | 339 | /** |
309 | * Called to initialise peer | 340 | * Called with a single peer in order to initialise that peer |
310 | */ | 341 | */ |
311 | InitPeer init_peer; | 342 | InitPeer init_peer; |
312 | 343 | ||
@@ -316,7 +347,7 @@ struct SingleTestRun | |||
316 | PreTest pre_test; | 347 | PreTest pre_test; |
317 | 348 | ||
318 | /** | 349 | /** |
319 | * Function to execute the functions to be tested | 350 | * Main function for each peer |
320 | */ | 351 | */ |
321 | MainTest main_test; | 352 | MainTest main_test; |
322 | 353 | ||
@@ -502,6 +533,8 @@ shutdown_op (void *cls) | |||
502 | { | 533 | { |
503 | unsigned int i; | 534 | unsigned int i; |
504 | 535 | ||
536 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
537 | "Shutdown task scheduled, going down.\n"); | ||
505 | in_shutdown = GNUNET_YES; | 538 | in_shutdown = GNUNET_YES; |
506 | if (NULL != churn_task) | 539 | if (NULL != churn_task) |
507 | { | 540 | { |
@@ -583,6 +616,11 @@ info_cb (void *cb_cls, | |||
583 | { | 616 | { |
584 | struct OpListEntry *entry = (struct OpListEntry *) cb_cls; | 617 | struct OpListEntry *entry = (struct OpListEntry *) cb_cls; |
585 | 618 | ||
619 | if (GNUNET_YES == in_shutdown) | ||
620 | { | ||
621 | return; | ||
622 | } | ||
623 | |||
586 | if (NULL == pinfo || NULL != emsg) | 624 | if (NULL == pinfo || NULL != emsg) |
587 | { | 625 | { |
588 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg); | 626 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg); |
@@ -632,6 +670,11 @@ rps_connect_complete_cb (void *cls, | |||
632 | struct RPSPeer *rps_peer = cls; | 670 | struct RPSPeer *rps_peer = cls; |
633 | struct GNUNET_RPS_Handle *rps = ca_result; | 671 | struct GNUNET_RPS_Handle *rps = ca_result; |
634 | 672 | ||
673 | if (GNUNET_YES == in_shutdown) | ||
674 | { | ||
675 | return; | ||
676 | } | ||
677 | |||
635 | rps_peer->rps_handle = rps; | 678 | rps_peer->rps_handle = rps; |
636 | rps_peer->online = GNUNET_YES; | 679 | rps_peer->online = GNUNET_YES; |
637 | num_peers_online++; | 680 | num_peers_online++; |
@@ -758,9 +801,13 @@ default_reply_handle (void *cls, | |||
758 | rps_peer->num_recv_ids++; | 801 | rps_peer->num_recv_ids++; |
759 | } | 802 | } |
760 | 803 | ||
761 | if (0 == evaluate ()) | 804 | if (0 == evaluate () && 0 != strncmp (cur_test_run.name, "test-rps-churn", 14)) |
762 | { | 805 | { |
763 | GNUNET_SCHEDULER_shutdown (); | 806 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n"); |
807 | GNUNET_assert (NULL != shutdown_task); | ||
808 | GNUNET_SCHEDULER_cancel (shutdown_task); | ||
809 | shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL); | ||
810 | GNUNET_assert (NULL!= shutdown_task); | ||
764 | } | 811 | } |
765 | } | 812 | } |
766 | 813 | ||
@@ -904,12 +951,20 @@ static void mal_init_peer (struct RPSPeer *rps_peer) | |||
904 | rps_peer->num_ids_to_request = 1; | 951 | rps_peer->num_ids_to_request = 1; |
905 | } | 952 | } |
906 | 953 | ||
954 | |||
955 | /** | ||
956 | * @brief Set peers to (non-)malicious before execution | ||
957 | * | ||
958 | * Of signature #PreTest | ||
959 | * | ||
960 | * @param rps_peer the peer to set (non-) malicious | ||
961 | * @param h the handle to the service | ||
962 | */ | ||
907 | static void | 963 | static void |
908 | mal_pre (void *cls, struct GNUNET_RPS_Handle *h) | 964 | mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) |
909 | { | 965 | { |
910 | #ifdef ENABLE_MALICIOUS | 966 | #ifdef ENABLE_MALICIOUS |
911 | uint32_t num_mal_peers; | 967 | uint32_t num_mal_peers; |
912 | struct RPSPeer *rps_peer = (struct RPSPeer *) cls; | ||
913 | 968 | ||
914 | GNUNET_assert ( (1 >= portion) && | 969 | GNUNET_assert ( (1 >= portion) && |
915 | (0 < portion) ); | 970 | (0 < portion) ); |
@@ -934,6 +989,11 @@ mal_cb (struct RPSPeer *rps_peer) | |||
934 | { | 989 | { |
935 | uint32_t num_mal_peers; | 990 | uint32_t num_mal_peers; |
936 | 991 | ||
992 | if (GNUNET_YES == in_shutdown) | ||
993 | { | ||
994 | return; | ||
995 | } | ||
996 | |||
937 | #ifdef ENABLE_MALICIOUS | 997 | #ifdef ENABLE_MALICIOUS |
938 | GNUNET_assert ( (1 >= portion) && | 998 | GNUNET_assert ( (1 >= portion) && |
939 | (0 < portion) ); | 999 | (0 < portion) ); |
@@ -956,6 +1016,11 @@ mal_cb (struct RPSPeer *rps_peer) | |||
956 | static void | 1016 | static void |
957 | single_req_cb (struct RPSPeer *rps_peer) | 1017 | single_req_cb (struct RPSPeer *rps_peer) |
958 | { | 1018 | { |
1019 | if (GNUNET_YES == in_shutdown) | ||
1020 | { | ||
1021 | return; | ||
1022 | } | ||
1023 | |||
959 | schedule_missing_requests (rps_peer); | 1024 | schedule_missing_requests (rps_peer); |
960 | } | 1025 | } |
961 | 1026 | ||
@@ -965,6 +1030,11 @@ single_req_cb (struct RPSPeer *rps_peer) | |||
965 | static void | 1030 | static void |
966 | delay_req_cb (struct RPSPeer *rps_peer) | 1031 | delay_req_cb (struct RPSPeer *rps_peer) |
967 | { | 1032 | { |
1033 | if (GNUNET_YES == in_shutdown) | ||
1034 | { | ||
1035 | return; | ||
1036 | } | ||
1037 | |||
968 | schedule_missing_requests (rps_peer); | 1038 | schedule_missing_requests (rps_peer); |
969 | } | 1039 | } |
970 | 1040 | ||
@@ -974,6 +1044,11 @@ delay_req_cb (struct RPSPeer *rps_peer) | |||
974 | static void | 1044 | static void |
975 | seed_cb (struct RPSPeer *rps_peer) | 1045 | seed_cb (struct RPSPeer *rps_peer) |
976 | { | 1046 | { |
1047 | if (GNUNET_YES == in_shutdown) | ||
1048 | { | ||
1049 | return; | ||
1050 | } | ||
1051 | |||
977 | GNUNET_SCHEDULER_add_delayed ( | 1052 | GNUNET_SCHEDULER_add_delayed ( |
978 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), | 1053 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), |
979 | seed_peers, rps_peer); | 1054 | seed_peers, rps_peer); |
@@ -985,6 +1060,11 @@ seed_cb (struct RPSPeer *rps_peer) | |||
985 | static void | 1060 | static void |
986 | seed_big_cb (struct RPSPeer *rps_peer) | 1061 | seed_big_cb (struct RPSPeer *rps_peer) |
987 | { | 1062 | { |
1063 | if (GNUNET_YES == in_shutdown) | ||
1064 | { | ||
1065 | return; | ||
1066 | } | ||
1067 | |||
988 | // TODO test seeding > GNUNET_MAX_MESSAGE_SIZE peers | 1068 | // TODO test seeding > GNUNET_MAX_MESSAGE_SIZE peers |
989 | GNUNET_SCHEDULER_add_delayed ( | 1069 | GNUNET_SCHEDULER_add_delayed ( |
990 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), | 1070 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), |
@@ -1006,6 +1086,11 @@ single_peer_seed_cb (struct RPSPeer *rps_peer) | |||
1006 | static void | 1086 | static void |
1007 | seed_req_cb (struct RPSPeer *rps_peer) | 1087 | seed_req_cb (struct RPSPeer *rps_peer) |
1008 | { | 1088 | { |
1089 | if (GNUNET_YES == in_shutdown) | ||
1090 | { | ||
1091 | return; | ||
1092 | } | ||
1093 | |||
1009 | GNUNET_SCHEDULER_add_delayed ( | 1094 | GNUNET_SCHEDULER_add_delayed ( |
1010 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), | 1095 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), |
1011 | seed_peers, rps_peer); | 1096 | seed_peers, rps_peer); |
@@ -1020,6 +1105,11 @@ seed_req_cb (struct RPSPeer *rps_peer) | |||
1020 | static void | 1105 | static void |
1021 | req_cancel_cb (struct RPSPeer *rps_peer) | 1106 | req_cancel_cb (struct RPSPeer *rps_peer) |
1022 | { | 1107 | { |
1108 | if (GNUNET_YES == in_shutdown) | ||
1109 | { | ||
1110 | return; | ||
1111 | } | ||
1112 | |||
1023 | schedule_missing_requests (rps_peer); | 1113 | schedule_missing_requests (rps_peer); |
1024 | GNUNET_SCHEDULER_add_delayed ( | 1114 | GNUNET_SCHEDULER_add_delayed ( |
1025 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 1115 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
@@ -1034,9 +1124,25 @@ req_cancel_cb (struct RPSPeer *rps_peer) | |||
1034 | static void | 1124 | static void |
1035 | churn (void *cls); | 1125 | churn (void *cls); |
1036 | 1126 | ||
1127 | /** | ||
1128 | * @brief Starts churn | ||
1129 | * | ||
1130 | * Has signature of #MainTest | ||
1131 | * | ||
1132 | * This is not implemented too nicely as this is called for each peer, but we | ||
1133 | * only need to call it once. (Yes we check that we only schedule the task | ||
1134 | * once.) | ||
1135 | * | ||
1136 | * @param rps_peer The peer it's called for | ||
1137 | */ | ||
1037 | static void | 1138 | static void |
1038 | churn_test_cb (struct RPSPeer *rps_peer) | 1139 | churn_test_cb (struct RPSPeer *rps_peer) |
1039 | { | 1140 | { |
1141 | if (GNUNET_YES == in_shutdown) | ||
1142 | { | ||
1143 | return; | ||
1144 | } | ||
1145 | |||
1040 | /* Start churn */ | 1146 | /* Start churn */ |
1041 | if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) | 1147 | if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) |
1042 | { | 1148 | { |
@@ -1073,6 +1179,11 @@ churn_cb (void *cls, | |||
1073 | // FIXME | 1179 | // FIXME |
1074 | struct OpListEntry *entry = cls; | 1180 | struct OpListEntry *entry = cls; |
1075 | 1181 | ||
1182 | if (GNUNET_YES == in_shutdown) | ||
1183 | { | ||
1184 | return; | ||
1185 | } | ||
1186 | |||
1076 | GNUNET_TESTBED_operation_done (entry->op); | 1187 | GNUNET_TESTBED_operation_done (entry->op); |
1077 | if (NULL != emsg) | 1188 | if (NULL != emsg) |
1078 | { | 1189 | { |
@@ -1084,7 +1195,7 @@ churn_cb (void *cls, | |||
1084 | 1195 | ||
1085 | num_peers_online += entry->delta; | 1196 | num_peers_online += entry->delta; |
1086 | 1197 | ||
1087 | if (0 > entry->delta) | 1198 | if (PEER_GO_OFFLINE == entry->delta) |
1088 | { /* Peer hopefully just went offline */ | 1199 | { /* Peer hopefully just went offline */ |
1089 | if (GNUNET_YES != rps_peers[entry->index].online) | 1200 | if (GNUNET_YES != rps_peers[entry->index].online) |
1090 | { | 1201 | { |
@@ -1102,7 +1213,7 @@ churn_cb (void *cls, | |||
1102 | rps_peers[entry->index].online = GNUNET_NO; | 1213 | rps_peers[entry->index].online = GNUNET_NO; |
1103 | } | 1214 | } |
1104 | 1215 | ||
1105 | else if (0 < entry->delta) | 1216 | else if (PEER_GO_ONLINE < entry->delta) |
1106 | { /* Peer hopefully just went online */ | 1217 | { /* Peer hopefully just went online */ |
1107 | if (GNUNET_NO != rps_peers[entry->index].online) | 1218 | if (GNUNET_NO != rps_peers[entry->index].online) |
1108 | { | 1219 | { |
@@ -1125,20 +1236,42 @@ churn_cb (void *cls, | |||
1125 | } | 1236 | } |
1126 | rps_peers[entry->index].online = GNUNET_YES; | 1237 | rps_peers[entry->index].online = GNUNET_YES; |
1127 | } | 1238 | } |
1239 | else | ||
1240 | { | ||
1241 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1242 | "Invalid value for delta: %i\n", entry->delta); | ||
1243 | GNUNET_break (0); | ||
1244 | } | ||
1128 | 1245 | ||
1129 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); | 1246 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); |
1247 | rps_peers[entry->index].entry_op_manage = NULL; | ||
1130 | GNUNET_free (entry); | 1248 | GNUNET_free (entry); |
1131 | //if (num_peers_in_round[current_round] == peers_running) | 1249 | //if (num_peers_in_round[current_round] == peers_running) |
1132 | // run_round (); | 1250 | // run_round (); |
1133 | } | 1251 | } |
1134 | 1252 | ||
1253 | /** | ||
1254 | * @brief Set the rps-service up or down for a specific peer | ||
1255 | * | ||
1256 | * @param i index of action | ||
1257 | * @param j index of peer | ||
1258 | * @param delta (#PEER_ONLINE_DELTA) down (-1) or up (1) | ||
1259 | * @param prob_go_on_off the probability of the action | ||
1260 | */ | ||
1135 | static void | 1261 | static void |
1136 | manage_service_wrapper (unsigned int i, unsigned int j, int delta, | 1262 | manage_service_wrapper (unsigned int i, unsigned int j, |
1137 | double prob_go_on_off) | 1263 | enum PEER_ONLINE_DELTA delta, |
1264 | double prob_go_on_off) | ||
1138 | { | 1265 | { |
1139 | struct OpListEntry *entry; | 1266 | struct OpListEntry *entry; |
1140 | uint32_t prob; | 1267 | uint32_t prob; |
1141 | 1268 | ||
1269 | /* make sure that management operation is not already scheduled */ | ||
1270 | if (NULL != rps_peers[j].entry_op_manage) | ||
1271 | { | ||
1272 | return; | ||
1273 | } | ||
1274 | |||
1142 | prob = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 1275 | prob = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
1143 | UINT32_MAX); | 1276 | UINT32_MAX); |
1144 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1277 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1146,15 +1279,15 @@ manage_service_wrapper (unsigned int i, unsigned int j, int delta, | |||
1146 | i, | 1279 | i, |
1147 | j, | 1280 | j, |
1148 | GNUNET_i2s (rps_peers[j].peer_id), | 1281 | GNUNET_i2s (rps_peers[j].peer_id), |
1149 | (0 > delta) ? "online" : "offline"); | 1282 | (PEER_GO_ONLINE == delta) ? "online" : "offline"); |
1150 | if (prob < prob_go_on_off * UINT32_MAX) | 1283 | if (prob < prob_go_on_off * UINT32_MAX) |
1151 | { | 1284 | { |
1152 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1285 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1153 | "%s goes %s\n", | 1286 | "%s goes %s\n", |
1154 | GNUNET_i2s (rps_peers[j].peer_id), | 1287 | GNUNET_i2s (rps_peers[j].peer_id), |
1155 | (0 > delta) ? "offline" : "online"); | 1288 | (PEER_GO_OFFLINE == delta) ? "offline" : "online"); |
1156 | 1289 | ||
1157 | if (0 > delta) | 1290 | if (PEER_GO_OFFLINE == delta) |
1158 | cancel_pending_req_rep (&rps_peers[j]); | 1291 | cancel_pending_req_rep (&rps_peers[j]); |
1159 | entry = make_oplist_entry (); | 1292 | entry = make_oplist_entry (); |
1160 | entry->delta = delta; | 1293 | entry->delta = delta; |
@@ -1164,8 +1297,9 @@ manage_service_wrapper (unsigned int i, unsigned int j, int delta, | |||
1164 | "rps", | 1297 | "rps", |
1165 | &churn_cb, | 1298 | &churn_cb, |
1166 | entry, | 1299 | entry, |
1167 | (0 > delta) ? 0 : 1); | 1300 | (PEER_GO_OFFLINE == delta) ? 0 : 1); |
1168 | } | 1301 | } |
1302 | rps_peers[j].entry_op_manage = entry; | ||
1169 | } | 1303 | } |
1170 | 1304 | ||
1171 | 1305 | ||
@@ -1180,9 +1314,15 @@ churn (void *cls) | |||
1180 | double portion_go_online; | 1314 | double portion_go_online; |
1181 | double portion_go_offline; | 1315 | double portion_go_offline; |
1182 | 1316 | ||
1317 | if (GNUNET_YES == in_shutdown) | ||
1318 | { | ||
1319 | return; | ||
1320 | } | ||
1183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1321 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1184 | "Churn function executing\n"); | 1322 | "Churn function executing\n"); |
1185 | 1323 | ||
1324 | churn_task = NULL; /* Should be invalid by now */ | ||
1325 | |||
1186 | /* Compute the probability for an online peer to go offline | 1326 | /* Compute the probability for an online peer to go offline |
1187 | * this round */ | 1327 | * this round */ |
1188 | portion_online = num_peers_online * 1.0 / num_peers; | 1328 | portion_online = num_peers_online * 1.0 / num_peers; |
@@ -1290,6 +1430,11 @@ profiler_reply_handle (void *cls, | |||
1290 | static void | 1430 | static void |
1291 | profiler_cb (struct RPSPeer *rps_peer) | 1431 | profiler_cb (struct RPSPeer *rps_peer) |
1292 | { | 1432 | { |
1433 | if (GNUNET_YES == in_shutdown) | ||
1434 | { | ||
1435 | return; | ||
1436 | } | ||
1437 | |||
1293 | /* Start churn */ | 1438 | /* Start churn */ |
1294 | if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) | 1439 | if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) |
1295 | { | 1440 | { |
@@ -1426,6 +1571,7 @@ run (void *cls, | |||
1426 | entry); | 1571 | entry); |
1427 | } | 1572 | } |
1428 | 1573 | ||
1574 | /* Bring peers up */ | ||
1429 | num_mal_peers = round (portion * num_peers); | 1575 | num_mal_peers = round (portion * num_peers); |
1430 | GNUNET_assert (num_peers == n_peers); | 1576 | GNUNET_assert (num_peers == n_peers); |
1431 | for (i = 0; i < n_peers; i++) | 1577 | for (i = 0; i < n_peers; i++) |
@@ -1448,7 +1594,7 @@ run (void *cls, | |||
1448 | 1594 | ||
1449 | if (NULL != churn_task) | 1595 | if (NULL != churn_task) |
1450 | GNUNET_SCHEDULER_cancel (churn_task); | 1596 | GNUNET_SCHEDULER_cancel (churn_task); |
1451 | GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); | 1597 | shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); |
1452 | } | 1598 | } |
1453 | 1599 | ||
1454 | 1600 | ||
@@ -1609,14 +1755,21 @@ main (int argc, char *argv[]) | |||
1609 | with the malicious portion */ | 1755 | with the malicious portion */ |
1610 | 1756 | ||
1611 | ok = 1; | 1757 | ok = 1; |
1612 | (void) GNUNET_TESTBED_test_run (cur_test_run.name, | 1758 | ret_value = GNUNET_TESTBED_test_run (cur_test_run.name, |
1613 | "test_rps.conf", | 1759 | "test_rps.conf", |
1614 | num_peers, | 1760 | num_peers, |
1615 | 0, NULL, NULL, | 1761 | 0, NULL, NULL, |
1616 | &run, NULL); | 1762 | &run, NULL); |
1763 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1764 | "_test_run returned.\n"); | ||
1765 | if (GNUNET_OK != ret_value) | ||
1766 | { | ||
1767 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1768 | "Test did not run successfully!\n"); | ||
1769 | } | ||
1617 | 1770 | ||
1618 | ret_value = cur_test_run.eval_cb(); | 1771 | ret_value = cur_test_run.eval_cb(); |
1619 | GNUNET_free (rps_peers ); | 1772 | GNUNET_free (rps_peers); |
1620 | GNUNET_free (rps_peer_ids); | 1773 | GNUNET_free (rps_peer_ids); |
1621 | GNUNET_CONTAINER_multipeermap_destroy (peer_map); | 1774 | GNUNET_CONTAINER_multipeermap_destroy (peer_map); |
1622 | return ret_value; | 1775 | return ret_value; |