diff options
author | Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de> | 2018-01-08 07:58:36 +0100 |
---|---|---|
committer | Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de> | 2018-01-08 07:58:36 +0100 |
commit | 3f52ce03cb13118bef9a6fbe380f229e2cbec45f (patch) | |
tree | 0f986c12192fcdd5d05fe575f66f01a0cf5ddf4e /src/rps/test_rps.c | |
parent | 7ad94d1427d304483e9bf1cf1d12065f8e41d712 (diff) | |
parent | 0120859e1ea2f0591602f446d4bc054e9230c801 (diff) | |
download | gnunet-3f52ce03cb13118bef9a6fbe380f229e2cbec45f.tar.gz gnunet-3f52ce03cb13118bef9a6fbe380f229e2cbec45f.zip |
Merge branch 'master' of git+ssh://gnunet.org/gnunet
Diffstat (limited to 'src/rps/test_rps.c')
-rw-r--r-- | src/rps/test_rps.c | 212 |
1 files changed, 185 insertions, 27 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index 0114a19fe..2cc1ac62e 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++; |
@@ -760,7 +803,10 @@ default_reply_handle (void *cls, | |||
760 | 803 | ||
761 | if (0 == evaluate ()) | 804 | if (0 == evaluate ()) |
762 | { | 805 | { |
763 | GNUNET_SCHEDULER_shutdown (); | 806 | GNUNET_assert (NULL != shutdown_task); |
807 | GNUNET_SCHEDULER_cancel (shutdown_task); | ||
808 | shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL); | ||
809 | GNUNET_assert (NULL!= shutdown_task); | ||
764 | } | 810 | } |
765 | } | 811 | } |
766 | 812 | ||
@@ -904,12 +950,20 @@ static void mal_init_peer (struct RPSPeer *rps_peer) | |||
904 | rps_peer->num_ids_to_request = 1; | 950 | rps_peer->num_ids_to_request = 1; |
905 | } | 951 | } |
906 | 952 | ||
953 | |||
954 | /** | ||
955 | * @brief Set peers to (non-)malicious before execution | ||
956 | * | ||
957 | * Of signature #PreTest | ||
958 | * | ||
959 | * @param rps_peer the peer to set (non-) malicious | ||
960 | * @param h the handle to the service | ||
961 | */ | ||
907 | static void | 962 | static void |
908 | mal_pre (void *cls, struct GNUNET_RPS_Handle *h) | 963 | mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) |
909 | { | 964 | { |
910 | #ifdef ENABLE_MALICIOUS | 965 | #ifdef ENABLE_MALICIOUS |
911 | uint32_t num_mal_peers; | 966 | uint32_t num_mal_peers; |
912 | struct RPSPeer *rps_peer = (struct RPSPeer *) cls; | ||
913 | 967 | ||
914 | GNUNET_assert ( (1 >= portion) && | 968 | GNUNET_assert ( (1 >= portion) && |
915 | (0 < portion) ); | 969 | (0 < portion) ); |
@@ -934,6 +988,11 @@ mal_cb (struct RPSPeer *rps_peer) | |||
934 | { | 988 | { |
935 | uint32_t num_mal_peers; | 989 | uint32_t num_mal_peers; |
936 | 990 | ||
991 | if (GNUNET_YES == in_shutdown) | ||
992 | { | ||
993 | return; | ||
994 | } | ||
995 | |||
937 | #ifdef ENABLE_MALICIOUS | 996 | #ifdef ENABLE_MALICIOUS |
938 | GNUNET_assert ( (1 >= portion) && | 997 | GNUNET_assert ( (1 >= portion) && |
939 | (0 < portion) ); | 998 | (0 < portion) ); |
@@ -956,6 +1015,11 @@ mal_cb (struct RPSPeer *rps_peer) | |||
956 | static void | 1015 | static void |
957 | single_req_cb (struct RPSPeer *rps_peer) | 1016 | single_req_cb (struct RPSPeer *rps_peer) |
958 | { | 1017 | { |
1018 | if (GNUNET_YES == in_shutdown) | ||
1019 | { | ||
1020 | return; | ||
1021 | } | ||
1022 | |||
959 | schedule_missing_requests (rps_peer); | 1023 | schedule_missing_requests (rps_peer); |
960 | } | 1024 | } |
961 | 1025 | ||
@@ -965,6 +1029,11 @@ single_req_cb (struct RPSPeer *rps_peer) | |||
965 | static void | 1029 | static void |
966 | delay_req_cb (struct RPSPeer *rps_peer) | 1030 | delay_req_cb (struct RPSPeer *rps_peer) |
967 | { | 1031 | { |
1032 | if (GNUNET_YES == in_shutdown) | ||
1033 | { | ||
1034 | return; | ||
1035 | } | ||
1036 | |||
968 | schedule_missing_requests (rps_peer); | 1037 | schedule_missing_requests (rps_peer); |
969 | } | 1038 | } |
970 | 1039 | ||
@@ -974,6 +1043,11 @@ delay_req_cb (struct RPSPeer *rps_peer) | |||
974 | static void | 1043 | static void |
975 | seed_cb (struct RPSPeer *rps_peer) | 1044 | seed_cb (struct RPSPeer *rps_peer) |
976 | { | 1045 | { |
1046 | if (GNUNET_YES == in_shutdown) | ||
1047 | { | ||
1048 | return; | ||
1049 | } | ||
1050 | |||
977 | GNUNET_SCHEDULER_add_delayed ( | 1051 | GNUNET_SCHEDULER_add_delayed ( |
978 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), | 1052 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), |
979 | seed_peers, rps_peer); | 1053 | seed_peers, rps_peer); |
@@ -985,6 +1059,11 @@ seed_cb (struct RPSPeer *rps_peer) | |||
985 | static void | 1059 | static void |
986 | seed_big_cb (struct RPSPeer *rps_peer) | 1060 | seed_big_cb (struct RPSPeer *rps_peer) |
987 | { | 1061 | { |
1062 | if (GNUNET_YES == in_shutdown) | ||
1063 | { | ||
1064 | return; | ||
1065 | } | ||
1066 | |||
988 | // TODO test seeding > GNUNET_MAX_MESSAGE_SIZE peers | 1067 | // TODO test seeding > GNUNET_MAX_MESSAGE_SIZE peers |
989 | GNUNET_SCHEDULER_add_delayed ( | 1068 | GNUNET_SCHEDULER_add_delayed ( |
990 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), | 1069 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), |
@@ -1006,6 +1085,11 @@ single_peer_seed_cb (struct RPSPeer *rps_peer) | |||
1006 | static void | 1085 | static void |
1007 | seed_req_cb (struct RPSPeer *rps_peer) | 1086 | seed_req_cb (struct RPSPeer *rps_peer) |
1008 | { | 1087 | { |
1088 | if (GNUNET_YES == in_shutdown) | ||
1089 | { | ||
1090 | return; | ||
1091 | } | ||
1092 | |||
1009 | GNUNET_SCHEDULER_add_delayed ( | 1093 | GNUNET_SCHEDULER_add_delayed ( |
1010 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), | 1094 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), |
1011 | seed_peers, rps_peer); | 1095 | seed_peers, rps_peer); |
@@ -1020,6 +1104,11 @@ seed_req_cb (struct RPSPeer *rps_peer) | |||
1020 | static void | 1104 | static void |
1021 | req_cancel_cb (struct RPSPeer *rps_peer) | 1105 | req_cancel_cb (struct RPSPeer *rps_peer) |
1022 | { | 1106 | { |
1107 | if (GNUNET_YES == in_shutdown) | ||
1108 | { | ||
1109 | return; | ||
1110 | } | ||
1111 | |||
1023 | schedule_missing_requests (rps_peer); | 1112 | schedule_missing_requests (rps_peer); |
1024 | GNUNET_SCHEDULER_add_delayed ( | 1113 | GNUNET_SCHEDULER_add_delayed ( |
1025 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 1114 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
@@ -1034,9 +1123,25 @@ req_cancel_cb (struct RPSPeer *rps_peer) | |||
1034 | static void | 1123 | static void |
1035 | churn (void *cls); | 1124 | churn (void *cls); |
1036 | 1125 | ||
1126 | /** | ||
1127 | * @brief Starts churn | ||
1128 | * | ||
1129 | * Has signature of #MainTest | ||
1130 | * | ||
1131 | * This is not implemented too nicely as this is called for each peer, but we | ||
1132 | * only need to call it once. (Yes we check that we only schedule the task | ||
1133 | * once.) | ||
1134 | * | ||
1135 | * @param rps_peer The peer it's called for | ||
1136 | */ | ||
1037 | static void | 1137 | static void |
1038 | churn_test_cb (struct RPSPeer *rps_peer) | 1138 | churn_test_cb (struct RPSPeer *rps_peer) |
1039 | { | 1139 | { |
1140 | if (GNUNET_YES == in_shutdown) | ||
1141 | { | ||
1142 | return; | ||
1143 | } | ||
1144 | |||
1040 | /* Start churn */ | 1145 | /* Start churn */ |
1041 | if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) | 1146 | if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) |
1042 | { | 1147 | { |
@@ -1073,6 +1178,11 @@ churn_cb (void *cls, | |||
1073 | // FIXME | 1178 | // FIXME |
1074 | struct OpListEntry *entry = cls; | 1179 | struct OpListEntry *entry = cls; |
1075 | 1180 | ||
1181 | if (GNUNET_YES == in_shutdown) | ||
1182 | { | ||
1183 | return; | ||
1184 | } | ||
1185 | |||
1076 | GNUNET_TESTBED_operation_done (entry->op); | 1186 | GNUNET_TESTBED_operation_done (entry->op); |
1077 | if (NULL != emsg) | 1187 | if (NULL != emsg) |
1078 | { | 1188 | { |
@@ -1084,7 +1194,7 @@ churn_cb (void *cls, | |||
1084 | 1194 | ||
1085 | num_peers_online += entry->delta; | 1195 | num_peers_online += entry->delta; |
1086 | 1196 | ||
1087 | if (0 > entry->delta) | 1197 | if (PEER_GO_OFFLINE == entry->delta) |
1088 | { /* Peer hopefully just went offline */ | 1198 | { /* Peer hopefully just went offline */ |
1089 | if (GNUNET_YES != rps_peers[entry->index].online) | 1199 | if (GNUNET_YES != rps_peers[entry->index].online) |
1090 | { | 1200 | { |
@@ -1102,7 +1212,7 @@ churn_cb (void *cls, | |||
1102 | rps_peers[entry->index].online = GNUNET_NO; | 1212 | rps_peers[entry->index].online = GNUNET_NO; |
1103 | } | 1213 | } |
1104 | 1214 | ||
1105 | else if (0 < entry->delta) | 1215 | else if (PEER_GO_ONLINE < entry->delta) |
1106 | { /* Peer hopefully just went online */ | 1216 | { /* Peer hopefully just went online */ |
1107 | if (GNUNET_NO != rps_peers[entry->index].online) | 1217 | if (GNUNET_NO != rps_peers[entry->index].online) |
1108 | { | 1218 | { |
@@ -1125,20 +1235,44 @@ churn_cb (void *cls, | |||
1125 | } | 1235 | } |
1126 | rps_peers[entry->index].online = GNUNET_YES; | 1236 | rps_peers[entry->index].online = GNUNET_YES; |
1127 | } | 1237 | } |
1238 | else | ||
1239 | { | ||
1240 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1241 | "Invalid value for delta: %i\n", entry->delta); | ||
1242 | GNUNET_break (0); | ||
1243 | } | ||
1128 | 1244 | ||
1129 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); | 1245 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); |
1246 | rps_peers[entry->index].entry_op_manage = NULL; | ||
1130 | GNUNET_free (entry); | 1247 | GNUNET_free (entry); |
1131 | //if (num_peers_in_round[current_round] == peers_running) | 1248 | //if (num_peers_in_round[current_round] == peers_running) |
1132 | // run_round (); | 1249 | // run_round (); |
1133 | } | 1250 | } |
1134 | 1251 | ||
1252 | /** | ||
1253 | * @brief Set the rps-service up or down for a specific peer | ||
1254 | * | ||
1255 | * @param i index of action | ||
1256 | * @param j index of peer | ||
1257 | * @param delta (#PEER_ONLINE_DELTA) down (-1) or up (1) | ||
1258 | * @param prob_go_on_off the probability of the action | ||
1259 | */ | ||
1135 | static void | 1260 | static void |
1136 | manage_service_wrapper (unsigned int i, unsigned int j, int delta, | 1261 | manage_service_wrapper (unsigned int i, unsigned int j, |
1137 | double prob_go_on_off) | 1262 | enum PEER_ONLINE_DELTA delta, |
1263 | double prob_go_on_off) | ||
1138 | { | 1264 | { |
1139 | struct OpListEntry *entry; | 1265 | struct OpListEntry *entry; |
1140 | uint32_t prob; | 1266 | uint32_t prob; |
1141 | 1267 | ||
1268 | GNUNET_assert (GNUNET_YES == rps_peers[j].online); | ||
1269 | |||
1270 | /* make sure that management operation is not already scheduled */ | ||
1271 | if (NULL != rps_peers[j].entry_op_manage) | ||
1272 | { | ||
1273 | return; | ||
1274 | } | ||
1275 | |||
1142 | prob = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 1276 | prob = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
1143 | UINT32_MAX); | 1277 | UINT32_MAX); |
1144 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1278 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1146,15 +1280,19 @@ manage_service_wrapper (unsigned int i, unsigned int j, int delta, | |||
1146 | i, | 1280 | i, |
1147 | j, | 1281 | j, |
1148 | GNUNET_i2s (rps_peers[j].peer_id), | 1282 | GNUNET_i2s (rps_peers[j].peer_id), |
1149 | (0 > delta) ? "online" : "offline"); | 1283 | (PEER_GO_ONLINE == delta) ? "online" : "offline"); |
1150 | if (prob < prob_go_on_off * UINT32_MAX) | 1284 | if (prob < prob_go_on_off * UINT32_MAX) |
1151 | { | 1285 | { |
1152 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1286 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1153 | "%s goes %s\n", | 1287 | "%s goes %s\n", |
1154 | GNUNET_i2s (rps_peers[j].peer_id), | 1288 | GNUNET_i2s (rps_peers[j].peer_id), |
1155 | (0 > delta) ? "offline" : "online"); | 1289 | (PEER_GO_OFFLINE == delta) ? "offline" : "online"); |
1290 | |||
1291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1292 | "testbed_peers points to %p, peer 0 to %p\n", | ||
1293 | testbed_peers, testbed_peers[0]); | ||
1156 | 1294 | ||
1157 | if (0 > delta) | 1295 | if (PEER_GO_OFFLINE == delta) |
1158 | cancel_pending_req_rep (&rps_peers[j]); | 1296 | cancel_pending_req_rep (&rps_peers[j]); |
1159 | entry = make_oplist_entry (); | 1297 | entry = make_oplist_entry (); |
1160 | entry->delta = delta; | 1298 | entry->delta = delta; |
@@ -1164,8 +1302,9 @@ manage_service_wrapper (unsigned int i, unsigned int j, int delta, | |||
1164 | "rps", | 1302 | "rps", |
1165 | &churn_cb, | 1303 | &churn_cb, |
1166 | entry, | 1304 | entry, |
1167 | (0 > delta) ? 0 : 1); | 1305 | (PEER_GO_OFFLINE == delta) ? 0 : 1); |
1168 | } | 1306 | } |
1307 | rps_peers[j].entry_op_manage = entry; | ||
1169 | } | 1308 | } |
1170 | 1309 | ||
1171 | 1310 | ||
@@ -1180,9 +1319,15 @@ churn (void *cls) | |||
1180 | double portion_go_online; | 1319 | double portion_go_online; |
1181 | double portion_go_offline; | 1320 | double portion_go_offline; |
1182 | 1321 | ||
1322 | if (GNUNET_YES == in_shutdown) | ||
1323 | { | ||
1324 | return; | ||
1325 | } | ||
1183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1326 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1184 | "Churn function executing\n"); | 1327 | "Churn function executing\n"); |
1185 | 1328 | ||
1329 | churn_task = NULL; /* Should be invalid by now */ | ||
1330 | |||
1186 | /* Compute the probability for an online peer to go offline | 1331 | /* Compute the probability for an online peer to go offline |
1187 | * this round */ | 1332 | * this round */ |
1188 | portion_online = num_peers_online * 1.0 / num_peers; | 1333 | portion_online = num_peers_online * 1.0 / num_peers; |
@@ -1290,6 +1435,11 @@ profiler_reply_handle (void *cls, | |||
1290 | static void | 1435 | static void |
1291 | profiler_cb (struct RPSPeer *rps_peer) | 1436 | profiler_cb (struct RPSPeer *rps_peer) |
1292 | { | 1437 | { |
1438 | if (GNUNET_YES == in_shutdown) | ||
1439 | { | ||
1440 | return; | ||
1441 | } | ||
1442 | |||
1293 | /* Start churn */ | 1443 | /* Start churn */ |
1294 | if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) | 1444 | if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) |
1295 | { | 1445 | { |
@@ -1426,6 +1576,7 @@ run (void *cls, | |||
1426 | entry); | 1576 | entry); |
1427 | } | 1577 | } |
1428 | 1578 | ||
1579 | /* Bring peers up */ | ||
1429 | num_mal_peers = round (portion * num_peers); | 1580 | num_mal_peers = round (portion * num_peers); |
1430 | GNUNET_assert (num_peers == n_peers); | 1581 | GNUNET_assert (num_peers == n_peers); |
1431 | for (i = 0; i < n_peers; i++) | 1582 | for (i = 0; i < n_peers; i++) |
@@ -1448,7 +1599,7 @@ run (void *cls, | |||
1448 | 1599 | ||
1449 | if (NULL != churn_task) | 1600 | if (NULL != churn_task) |
1450 | GNUNET_SCHEDULER_cancel (churn_task); | 1601 | GNUNET_SCHEDULER_cancel (churn_task); |
1451 | GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); | 1602 | shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); |
1452 | } | 1603 | } |
1453 | 1604 | ||
1454 | 1605 | ||
@@ -1609,14 +1760,21 @@ main (int argc, char *argv[]) | |||
1609 | with the malicious portion */ | 1760 | with the malicious portion */ |
1610 | 1761 | ||
1611 | ok = 1; | 1762 | ok = 1; |
1612 | (void) GNUNET_TESTBED_test_run (cur_test_run.name, | 1763 | ret_value = GNUNET_TESTBED_test_run (cur_test_run.name, |
1613 | "test_rps.conf", | 1764 | "test_rps.conf", |
1614 | num_peers, | 1765 | num_peers, |
1615 | 0, NULL, NULL, | 1766 | 0, NULL, NULL, |
1616 | &run, NULL); | 1767 | &run, NULL); |
1768 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1769 | "_test_run returned.\n"); | ||
1770 | if (GNUNET_OK != ret_value) | ||
1771 | { | ||
1772 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1773 | "Test did not run successfully!\n"); | ||
1774 | } | ||
1617 | 1775 | ||
1618 | ret_value = cur_test_run.eval_cb(); | 1776 | ret_value = cur_test_run.eval_cb(); |
1619 | GNUNET_free (rps_peers ); | 1777 | GNUNET_free (rps_peers); |
1620 | GNUNET_free (rps_peer_ids); | 1778 | GNUNET_free (rps_peer_ids); |
1621 | GNUNET_CONTAINER_multipeermap_destroy (peer_map); | 1779 | GNUNET_CONTAINER_multipeermap_destroy (peer_map); |
1622 | return ret_value; | 1780 | return ret_value; |