diff options
Diffstat (limited to 'src/rps/test_rps.c')
-rw-r--r-- | src/rps/test_rps.c | 157 |
1 files changed, 109 insertions, 48 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index 3a01e73ff..81cf63c72 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -623,9 +623,7 @@ tofile_ (const char *file_name, const char *line) | |||
623 | "Failed to write string to buffer (size: %i)\n", | 623 | "Failed to write string to buffer (size: %i)\n", |
624 | size); | 624 | size); |
625 | return; | 625 | return; |
626 | } */ | 626 | } */size = strlen (line) * sizeof(char); |
627 | |||
628 | size = strlen (line) * sizeof(char); | ||
629 | 627 | ||
630 | size2 = GNUNET_DISK_file_write (f, line, size); | 628 | size2 = GNUNET_DISK_file_write (f, line, size); |
631 | if (size != size2) | 629 | if (size != size2) |
@@ -649,6 +647,7 @@ tofile_ (const char *file_name, const char *line) | |||
649 | } | 647 | } |
650 | } | 648 | } |
651 | 649 | ||
650 | |||
652 | /** | 651 | /** |
653 | * This function is used to facilitate writing important information to disk | 652 | * This function is used to facilitate writing important information to disk |
654 | */ | 653 | */ |
@@ -740,7 +739,8 @@ make_oplist_entry () | |||
740 | * @return #GNUNET_YES if so | 739 | * @return #GNUNET_YES if so |
741 | * #GNUNET_NO otherwise | 740 | * #GNUNET_NO otherwise |
742 | */ | 741 | */ |
743 | static int check_statistics_collect_completed_single_peer ( | 742 | static int |
743 | check_statistics_collect_completed_single_peer ( | ||
744 | const struct RPSPeer *rps_peer) | 744 | const struct RPSPeer *rps_peer) |
745 | { | 745 | { |
746 | if (cur_test_run.stat_collect_flags != | 746 | if (cur_test_run.stat_collect_flags != |
@@ -760,7 +760,8 @@ static int check_statistics_collect_completed_single_peer ( | |||
760 | * @return #GNUNET_YES if so | 760 | * @return #GNUNET_YES if so |
761 | * #GNUNET_NO otherwise | 761 | * #GNUNET_NO otherwise |
762 | */ | 762 | */ |
763 | static int check_statistics_collect_completed () | 763 | static int |
764 | check_statistics_collect_completed () | ||
764 | { | 765 | { |
765 | uint32_t i; | 766 | uint32_t i; |
766 | 767 | ||
@@ -853,7 +854,7 @@ post_test_op (void *cls) | |||
853 | } | 854 | } |
854 | } | 855 | } |
855 | /* If we do not collect statistics, shut down directly */ | 856 | /* If we do not collect statistics, shut down directly */ |
856 | if ((NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics)|| | 857 | if ((NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics) || |
857 | (GNUNET_YES == check_statistics_collect_completed ()) ) | 858 | (GNUNET_YES == check_statistics_collect_completed ()) ) |
858 | { | 859 | { |
859 | GNUNET_SCHEDULER_shutdown (); | 860 | GNUNET_SCHEDULER_shutdown (); |
@@ -871,7 +872,7 @@ seed_peers (void *cls) | |||
871 | unsigned int amount; | 872 | unsigned int amount; |
872 | unsigned int i; | 873 | unsigned int i; |
873 | 874 | ||
874 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 875 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
875 | { | 876 | { |
876 | return; | 877 | return; |
877 | } | 878 | } |
@@ -925,6 +926,7 @@ seed_peers_big (void *cls) | |||
925 | GNUNET_RPS_seed_ids (peer->rps_handle, amount, ids_to_seed); | 926 | GNUNET_RPS_seed_ids (peer->rps_handle, amount, ids_to_seed); |
926 | } | 927 | } |
927 | 928 | ||
929 | |||
928 | /** | 930 | /** |
929 | * Get the id of peer i. | 931 | * Get the id of peer i. |
930 | */ | 932 | */ |
@@ -938,12 +940,12 @@ info_cb (void *cb_cls, | |||
938 | 940 | ||
939 | (void) op; | 941 | (void) op; |
940 | 942 | ||
941 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 943 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
942 | { | 944 | { |
943 | return; | 945 | return; |
944 | } | 946 | } |
945 | 947 | ||
946 | if ((NULL == pinfo)||(NULL != emsg)) | 948 | if ((NULL == pinfo) || (NULL != emsg)) |
947 | { | 949 | { |
948 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg); | 950 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg); |
949 | GNUNET_TESTBED_operation_done (entry->op); | 951 | GNUNET_TESTBED_operation_done (entry->op); |
@@ -994,7 +996,7 @@ rps_connect_complete_cb (void *cls, | |||
994 | 996 | ||
995 | GNUNET_assert (NULL != ca_result); | 997 | GNUNET_assert (NULL != ca_result); |
996 | 998 | ||
997 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 999 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
998 | { | 1000 | { |
999 | return; | 1001 | return; |
1000 | } | 1002 | } |
@@ -1046,6 +1048,7 @@ rps_connect_adapter (void *cls, | |||
1046 | return h; | 1048 | return h; |
1047 | } | 1049 | } |
1048 | 1050 | ||
1051 | |||
1049 | /** | 1052 | /** |
1050 | * Called to open a connection to the peer's statistics | 1053 | * Called to open a connection to the peer's statistics |
1051 | * | 1054 | * |
@@ -1065,6 +1068,7 @@ stat_connect_adapter (void *cls, | |||
1065 | return peer->stats_h; | 1068 | return peer->stats_h; |
1066 | } | 1069 | } |
1067 | 1070 | ||
1071 | |||
1068 | /** | 1072 | /** |
1069 | * Called to disconnect from peer's statistics service | 1073 | * Called to disconnect from peer's statistics service |
1070 | * | 1074 | * |
@@ -1086,6 +1090,7 @@ stat_disconnect_adapter (void *cls, void *op_result) | |||
1086 | peer->stats_h = NULL; | 1090 | peer->stats_h = NULL; |
1087 | } | 1091 | } |
1088 | 1092 | ||
1093 | |||
1089 | /** | 1094 | /** |
1090 | * Called after successfully opening a connection to a peer's statistics | 1095 | * Called after successfully opening a connection to a peer's statistics |
1091 | * service; we register statistics monitoring for CORE and NSE here. | 1096 | * service; we register statistics monitoring for CORE and NSE here. |
@@ -1156,20 +1161,24 @@ default_eval_cb (void) | |||
1156 | return evaluate (); | 1161 | return evaluate (); |
1157 | } | 1162 | } |
1158 | 1163 | ||
1164 | |||
1159 | static int | 1165 | static int |
1160 | no_eval (void) | 1166 | no_eval (void) |
1161 | { | 1167 | { |
1162 | return 0; | 1168 | return 0; |
1163 | } | 1169 | } |
1164 | 1170 | ||
1171 | |||
1165 | /** | 1172 | /** |
1166 | * Initialise given RPSPeer | 1173 | * Initialise given RPSPeer |
1167 | */ | 1174 | */ |
1168 | static void default_init_peer (struct RPSPeer *rps_peer) | 1175 | static void |
1176 | default_init_peer (struct RPSPeer *rps_peer) | ||
1169 | { | 1177 | { |
1170 | rps_peer->num_ids_to_request = 1; | 1178 | rps_peer->num_ids_to_request = 1; |
1171 | } | 1179 | } |
1172 | 1180 | ||
1181 | |||
1173 | /** | 1182 | /** |
1174 | * Callback to call on receipt of a reply | 1183 | * Callback to call on receipt of a reply |
1175 | * | 1184 | * |
@@ -1206,7 +1215,7 @@ default_reply_handle (void *cls, | |||
1206 | rps_peer->num_recv_ids++; | 1215 | rps_peer->num_recv_ids++; |
1207 | } | 1216 | } |
1208 | 1217 | ||
1209 | if ((0 == evaluate ())&&(HAVE_QUICK_QUIT == cur_test_run.have_quick_quit)) | 1218 | if ((0 == evaluate ()) && (HAVE_QUICK_QUIT == cur_test_run.have_quick_quit)) |
1210 | { | 1219 | { |
1211 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n"); | 1220 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n"); |
1212 | GNUNET_assert (NULL != post_test_task); | 1221 | GNUNET_assert (NULL != post_test_task); |
@@ -1216,6 +1225,7 @@ default_reply_handle (void *cls, | |||
1216 | } | 1225 | } |
1217 | } | 1226 | } |
1218 | 1227 | ||
1228 | |||
1219 | /** | 1229 | /** |
1220 | * Request random peers. | 1230 | * Request random peers. |
1221 | */ | 1231 | */ |
@@ -1226,7 +1236,7 @@ request_peers (void *cls) | |||
1226 | struct RPSPeer *rps_peer; | 1236 | struct RPSPeer *rps_peer; |
1227 | struct PendingReply *pending_rep; | 1237 | struct PendingReply *pending_rep; |
1228 | 1238 | ||
1229 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1239 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1230 | return; | 1240 | return; |
1231 | rps_peer = pending_req->rps_peer; | 1241 | rps_peer = pending_req->rps_peer; |
1232 | GNUNET_assert (1 <= rps_peer->num_pending_reqs); | 1242 | GNUNET_assert (1 <= rps_peer->num_pending_reqs); |
@@ -1248,6 +1258,7 @@ request_peers (void *cls) | |||
1248 | rps_peer->num_pending_reqs--; | 1258 | rps_peer->num_pending_reqs--; |
1249 | } | 1259 | } |
1250 | 1260 | ||
1261 | |||
1251 | static void | 1262 | static void |
1252 | cancel_pending_req (struct PendingRequest *pending_req) | 1263 | cancel_pending_req (struct PendingRequest *pending_req) |
1253 | { | 1264 | { |
@@ -1264,6 +1275,7 @@ cancel_pending_req (struct PendingRequest *pending_req) | |||
1264 | GNUNET_free (pending_req); | 1275 | GNUNET_free (pending_req); |
1265 | } | 1276 | } |
1266 | 1277 | ||
1278 | |||
1267 | static void | 1279 | static void |
1268 | cancel_request (struct PendingReply *pending_rep) | 1280 | cancel_request (struct PendingReply *pending_rep) |
1269 | { | 1281 | { |
@@ -1280,6 +1292,7 @@ cancel_request (struct PendingReply *pending_rep) | |||
1280 | GNUNET_free (pending_rep); | 1292 | GNUNET_free (pending_rep); |
1281 | } | 1293 | } |
1282 | 1294 | ||
1295 | |||
1283 | /** | 1296 | /** |
1284 | * Cancel a request. | 1297 | * Cancel a request. |
1285 | */ | 1298 | */ |
@@ -1289,7 +1302,7 @@ cancel_request_cb (void *cls) | |||
1289 | struct RPSPeer *rps_peer = cls; | 1302 | struct RPSPeer *rps_peer = cls; |
1290 | struct PendingReply *pending_rep; | 1303 | struct PendingReply *pending_rep; |
1291 | 1304 | ||
1292 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1305 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1293 | return; | 1306 | return; |
1294 | pending_rep = rps_peer->pending_rep_head; | 1307 | pending_rep = rps_peer->pending_rep_head; |
1295 | GNUNET_assert (1 <= rps_peer->num_pending_reps); | 1308 | GNUNET_assert (1 <= rps_peer->num_pending_reps); |
@@ -1330,6 +1343,7 @@ schedule_missing_requests (struct RPSPeer *rps_peer) | |||
1330 | } | 1343 | } |
1331 | } | 1344 | } |
1332 | 1345 | ||
1346 | |||
1333 | void | 1347 | void |
1334 | cancel_pending_req_rep (struct RPSPeer *rps_peer) | 1348 | cancel_pending_req_rep (struct RPSPeer *rps_peer) |
1335 | { | 1349 | { |
@@ -1343,6 +1357,7 @@ cancel_pending_req_rep (struct RPSPeer *rps_peer) | |||
1343 | GNUNET_assert (0 == rps_peer->num_pending_reps); | 1357 | GNUNET_assert (0 == rps_peer->num_pending_reps); |
1344 | } | 1358 | } |
1345 | 1359 | ||
1360 | |||
1346 | /*********************************** | 1361 | /*********************************** |
1347 | * MALICIOUS | 1362 | * MALICIOUS |
1348 | ***********************************/ | 1363 | ***********************************/ |
@@ -1350,7 +1365,8 @@ cancel_pending_req_rep (struct RPSPeer *rps_peer) | |||
1350 | /** | 1365 | /** |
1351 | * Initialise only non-mal RPSPeers | 1366 | * Initialise only non-mal RPSPeers |
1352 | */ | 1367 | */ |
1353 | static void mal_init_peer (struct RPSPeer *rps_peer) | 1368 | static void |
1369 | mal_init_peer (struct RPSPeer *rps_peer) | ||
1354 | { | 1370 | { |
1355 | if (rps_peer->index >= round (portion * num_peers)) | 1371 | if (rps_peer->index >= round (portion * num_peers)) |
1356 | rps_peer->num_ids_to_request = 1; | 1372 | rps_peer->num_ids_to_request = 1; |
@@ -1390,12 +1406,13 @@ mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) | |||
1390 | #endif /* ENABLE_MALICIOUS */ | 1406 | #endif /* ENABLE_MALICIOUS */ |
1391 | } | 1407 | } |
1392 | 1408 | ||
1409 | |||
1393 | static void | 1410 | static void |
1394 | mal_cb (struct RPSPeer *rps_peer) | 1411 | mal_cb (struct RPSPeer *rps_peer) |
1395 | { | 1412 | { |
1396 | uint32_t num_mal_peers; | 1413 | uint32_t num_mal_peers; |
1397 | 1414 | ||
1398 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1415 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1399 | { | 1416 | { |
1400 | return; | 1417 | return; |
1401 | } | 1418 | } |
@@ -1423,7 +1440,7 @@ mal_cb (struct RPSPeer *rps_peer) | |||
1423 | static void | 1440 | static void |
1424 | single_req_cb (struct RPSPeer *rps_peer) | 1441 | single_req_cb (struct RPSPeer *rps_peer) |
1425 | { | 1442 | { |
1426 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1443 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1427 | { | 1444 | { |
1428 | return; | 1445 | return; |
1429 | } | 1446 | } |
@@ -1431,13 +1448,14 @@ single_req_cb (struct RPSPeer *rps_peer) | |||
1431 | schedule_missing_requests (rps_peer); | 1448 | schedule_missing_requests (rps_peer); |
1432 | } | 1449 | } |
1433 | 1450 | ||
1451 | |||
1434 | /*********************************** | 1452 | /*********************************** |
1435 | * DELAYED_REQUESTS | 1453 | * DELAYED_REQUESTS |
1436 | ***********************************/ | 1454 | ***********************************/ |
1437 | static void | 1455 | static void |
1438 | delay_req_cb (struct RPSPeer *rps_peer) | 1456 | delay_req_cb (struct RPSPeer *rps_peer) |
1439 | { | 1457 | { |
1440 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1458 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1441 | { | 1459 | { |
1442 | return; | 1460 | return; |
1443 | } | 1461 | } |
@@ -1445,13 +1463,14 @@ delay_req_cb (struct RPSPeer *rps_peer) | |||
1445 | schedule_missing_requests (rps_peer); | 1463 | schedule_missing_requests (rps_peer); |
1446 | } | 1464 | } |
1447 | 1465 | ||
1466 | |||
1448 | /*********************************** | 1467 | /*********************************** |
1449 | * SEED | 1468 | * SEED |
1450 | ***********************************/ | 1469 | ***********************************/ |
1451 | static void | 1470 | static void |
1452 | seed_cb (struct RPSPeer *rps_peer) | 1471 | seed_cb (struct RPSPeer *rps_peer) |
1453 | { | 1472 | { |
1454 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1473 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1455 | { | 1474 | { |
1456 | return; | 1475 | return; |
1457 | } | 1476 | } |
@@ -1461,13 +1480,14 @@ seed_cb (struct RPSPeer *rps_peer) | |||
1461 | seed_peers, rps_peer); | 1480 | seed_peers, rps_peer); |
1462 | } | 1481 | } |
1463 | 1482 | ||
1483 | |||
1464 | /*********************************** | 1484 | /*********************************** |
1465 | * SEED_BIG | 1485 | * SEED_BIG |
1466 | ***********************************/ | 1486 | ***********************************/ |
1467 | static void | 1487 | static void |
1468 | seed_big_cb (struct RPSPeer *rps_peer) | 1488 | seed_big_cb (struct RPSPeer *rps_peer) |
1469 | { | 1489 | { |
1470 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1490 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1471 | { | 1491 | { |
1472 | return; | 1492 | return; |
1473 | } | 1493 | } |
@@ -1478,6 +1498,7 @@ seed_big_cb (struct RPSPeer *rps_peer) | |||
1478 | seed_peers_big, rps_peer); | 1498 | seed_peers_big, rps_peer); |
1479 | } | 1499 | } |
1480 | 1500 | ||
1501 | |||
1481 | /*********************************** | 1502 | /*********************************** |
1482 | * SINGLE_PEER_SEED | 1503 | * SINGLE_PEER_SEED |
1483 | ***********************************/ | 1504 | ***********************************/ |
@@ -1488,13 +1509,14 @@ single_peer_seed_cb (struct RPSPeer *rps_peer) | |||
1488 | // TODO | 1509 | // TODO |
1489 | } | 1510 | } |
1490 | 1511 | ||
1512 | |||
1491 | /*********************************** | 1513 | /*********************************** |
1492 | * SEED_REQUEST | 1514 | * SEED_REQUEST |
1493 | ***********************************/ | 1515 | ***********************************/ |
1494 | static void | 1516 | static void |
1495 | seed_req_cb (struct RPSPeer *rps_peer) | 1517 | seed_req_cb (struct RPSPeer *rps_peer) |
1496 | { | 1518 | { |
1497 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1519 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1498 | { | 1520 | { |
1499 | return; | 1521 | return; |
1500 | } | 1522 | } |
@@ -1505,6 +1527,7 @@ seed_req_cb (struct RPSPeer *rps_peer) | |||
1505 | schedule_missing_requests (rps_peer); | 1527 | schedule_missing_requests (rps_peer); |
1506 | } | 1528 | } |
1507 | 1529 | ||
1530 | |||
1508 | // TODO start big mal | 1531 | // TODO start big mal |
1509 | 1532 | ||
1510 | /*********************************** | 1533 | /*********************************** |
@@ -1513,7 +1536,7 @@ seed_req_cb (struct RPSPeer *rps_peer) | |||
1513 | static void | 1536 | static void |
1514 | req_cancel_cb (struct RPSPeer *rps_peer) | 1537 | req_cancel_cb (struct RPSPeer *rps_peer) |
1515 | { | 1538 | { |
1516 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1539 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1517 | { | 1540 | { |
1518 | return; | 1541 | return; |
1519 | } | 1542 | } |
@@ -1525,6 +1548,7 @@ req_cancel_cb (struct RPSPeer *rps_peer) | |||
1525 | cancel_request_cb, rps_peer); | 1548 | cancel_request_cb, rps_peer); |
1526 | } | 1549 | } |
1527 | 1550 | ||
1551 | |||
1528 | /*********************************** | 1552 | /*********************************** |
1529 | * CHURN | 1553 | * CHURN |
1530 | ***********************************/ | 1554 | ***********************************/ |
@@ -1546,13 +1570,13 @@ churn (void *cls); | |||
1546 | static void | 1570 | static void |
1547 | churn_test_cb (struct RPSPeer *rps_peer) | 1571 | churn_test_cb (struct RPSPeer *rps_peer) |
1548 | { | 1572 | { |
1549 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1573 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1550 | { | 1574 | { |
1551 | return; | 1575 | return; |
1552 | } | 1576 | } |
1553 | 1577 | ||
1554 | /* Start churn */ | 1578 | /* Start churn */ |
1555 | if ((HAVE_CHURN == cur_test_run.have_churn)&&(NULL == churn_task)) | 1579 | if ((HAVE_CHURN == cur_test_run.have_churn) && (NULL == churn_task)) |
1556 | { | 1580 | { |
1557 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1581 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1558 | "Starting churn task\n"); | 1582 | "Starting churn task\n"); |
@@ -1570,6 +1594,7 @@ churn_test_cb (struct RPSPeer *rps_peer) | |||
1570 | schedule_missing_requests (rps_peer); | 1594 | schedule_missing_requests (rps_peer); |
1571 | } | 1595 | } |
1572 | 1596 | ||
1597 | |||
1573 | /*********************************** | 1598 | /*********************************** |
1574 | * SUB | 1599 | * SUB |
1575 | ***********************************/ | 1600 | ***********************************/ |
@@ -1633,6 +1658,7 @@ sub_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) | |||
1633 | rps_peer); | 1658 | rps_peer); |
1634 | } | 1659 | } |
1635 | 1660 | ||
1661 | |||
1636 | /*********************************** | 1662 | /*********************************** |
1637 | * PROFILER | 1663 | * PROFILER |
1638 | ***********************************/ | 1664 | ***********************************/ |
@@ -1653,7 +1679,7 @@ churn_cb (void *cls, | |||
1653 | // FIXME | 1679 | // FIXME |
1654 | struct OpListEntry *entry = cls; | 1680 | struct OpListEntry *entry = cls; |
1655 | 1681 | ||
1656 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1682 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1657 | { | 1683 | { |
1658 | return; | 1684 | return; |
1659 | } | 1685 | } |
@@ -1725,6 +1751,7 @@ churn_cb (void *cls, | |||
1725 | // run_round (); | 1751 | // run_round (); |
1726 | } | 1752 | } |
1727 | 1753 | ||
1754 | |||
1728 | /** | 1755 | /** |
1729 | * @brief Set the rps-service up or down for a specific peer | 1756 | * @brief Set the rps-service up or down for a specific peer |
1730 | * | 1757 | * |
@@ -1791,7 +1818,7 @@ churn (void *cls) | |||
1791 | double portion_go_online; | 1818 | double portion_go_online; |
1792 | double portion_go_offline; | 1819 | double portion_go_offline; |
1793 | 1820 | ||
1794 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1821 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1795 | { | 1822 | { |
1796 | return; | 1823 | return; |
1797 | } | 1824 | } |
@@ -1852,7 +1879,8 @@ churn (void *cls) | |||
1852 | /** | 1879 | /** |
1853 | * Initialise given RPSPeer | 1880 | * Initialise given RPSPeer |
1854 | */ | 1881 | */ |
1855 | static void profiler_init_peer (struct RPSPeer *rps_peer) | 1882 | static void |
1883 | profiler_init_peer (struct RPSPeer *rps_peer) | ||
1856 | { | 1884 | { |
1857 | if (num_peers - 1 == rps_peer->index) | 1885 | if (num_peers - 1 == rps_peer->index) |
1858 | rps_peer->num_ids_to_request = cur_test_run.num_requests; | 1886 | rps_peer->num_ids_to_request = cur_test_run.num_requests; |
@@ -1907,13 +1935,13 @@ profiler_reply_handle (void *cls, | |||
1907 | static void | 1935 | static void |
1908 | profiler_cb (struct RPSPeer *rps_peer) | 1936 | profiler_cb (struct RPSPeer *rps_peer) |
1909 | { | 1937 | { |
1910 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1938 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1911 | { | 1939 | { |
1912 | return; | 1940 | return; |
1913 | } | 1941 | } |
1914 | 1942 | ||
1915 | /* Start churn */ | 1943 | /* Start churn */ |
1916 | if ((HAVE_CHURN == cur_test_run.have_churn)&&(NULL == churn_task)) | 1944 | if ((HAVE_CHURN == cur_test_run.have_churn) && (NULL == churn_task)) |
1917 | { | 1945 | { |
1918 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1946 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1919 | "Starting churn task\n"); | 1947 | "Starting churn task\n"); |
@@ -1935,6 +1963,7 @@ profiler_cb (struct RPSPeer *rps_peer) | |||
1935 | schedule_missing_requests (rps_peer); | 1963 | schedule_missing_requests (rps_peer); |
1936 | } | 1964 | } |
1937 | 1965 | ||
1966 | |||
1938 | /** | 1967 | /** |
1939 | * Function called from #profiler_eval with a filename. | 1968 | * Function called from #profiler_eval with a filename. |
1940 | * | 1969 | * |
@@ -1972,6 +2001,7 @@ file_name_cb (void *cls, const char *filename) | |||
1972 | return GNUNET_OK; | 2001 | return GNUNET_OK; |
1973 | } | 2002 | } |
1974 | 2003 | ||
2004 | |||
1975 | /** | 2005 | /** |
1976 | * This is run after the test finished. | 2006 | * This is run after the test finished. |
1977 | * | 2007 | * |
@@ -1998,7 +2028,8 @@ profiler_eval (void) | |||
1998 | * | 2028 | * |
1999 | * @return | 2029 | * @return |
2000 | */ | 2030 | */ |
2001 | static int is_in_view (uint32_t a, uint32_t b) | 2031 | static int |
2032 | is_in_view (uint32_t a, uint32_t b) | ||
2002 | { | 2033 | { |
2003 | uint32_t i; | 2034 | uint32_t i; |
2004 | 2035 | ||
@@ -2014,7 +2045,9 @@ static int is_in_view (uint32_t a, uint32_t b) | |||
2014 | return GNUNET_NO; | 2045 | return GNUNET_NO; |
2015 | } | 2046 | } |
2016 | 2047 | ||
2017 | static uint32_t get_idx_of_pid (const struct GNUNET_PeerIdentity *pid) | 2048 | |
2049 | static uint32_t | ||
2050 | get_idx_of_pid (const struct GNUNET_PeerIdentity *pid) | ||
2018 | { | 2051 | { |
2019 | uint32_t i; | 2052 | uint32_t i; |
2020 | 2053 | ||
@@ -2034,6 +2067,7 @@ static uint32_t get_idx_of_pid (const struct GNUNET_PeerIdentity *pid) | |||
2034 | GNUNET_assert (0); | 2067 | GNUNET_assert (0); |
2035 | } | 2068 | } |
2036 | 2069 | ||
2070 | |||
2037 | /** | 2071 | /** |
2038 | * @brief Counts number of peers in view of a that have b in their view | 2072 | * @brief Counts number of peers in view of a that have b in their view |
2039 | * | 2073 | * |
@@ -2042,7 +2076,8 @@ static uint32_t get_idx_of_pid (const struct GNUNET_PeerIdentity *pid) | |||
2042 | * | 2076 | * |
2043 | * @return | 2077 | * @return |
2044 | */ | 2078 | */ |
2045 | static uint32_t count_containing_views (uint32_t a, uint32_t b) | 2079 | static uint32_t |
2080 | count_containing_views (uint32_t a, uint32_t b) | ||
2046 | { | 2081 | { |
2047 | uint32_t i; | 2082 | uint32_t i; |
2048 | uint32_t peer_idx; | 2083 | uint32_t peer_idx; |
@@ -2059,13 +2094,15 @@ static uint32_t count_containing_views (uint32_t a, uint32_t b) | |||
2059 | return count; | 2094 | return count; |
2060 | } | 2095 | } |
2061 | 2096 | ||
2097 | |||
2062 | /** | 2098 | /** |
2063 | * @brief Computes the probability for each other peer to be selected by the | 2099 | * @brief Computes the probability for each other peer to be selected by the |
2064 | * sampling process based on the views of all peers | 2100 | * sampling process based on the views of all peers |
2065 | * | 2101 | * |
2066 | * @param peer_idx index of the peer that is about to sample | 2102 | * @param peer_idx index of the peer that is about to sample |
2067 | */ | 2103 | */ |
2068 | static void compute_probabilities (uint32_t peer_idx) | 2104 | static void |
2105 | compute_probabilities (uint32_t peer_idx) | ||
2069 | { | 2106 | { |
2070 | // double probs[num_peers] = { 0 }; | 2107 | // double probs[num_peers] = { 0 }; |
2071 | double probs[num_peers]; | 2108 | double probs[num_peers]; |
@@ -2197,6 +2234,7 @@ static void compute_probabilities (uint32_t peer_idx) | |||
2197 | GNUNET_free (probs_as_str); | 2234 | GNUNET_free (probs_as_str); |
2198 | } | 2235 | } |
2199 | 2236 | ||
2237 | |||
2200 | /** | 2238 | /** |
2201 | * @brief This counts the number of peers in which views a given peer occurs. | 2239 | * @brief This counts the number of peers in which views a given peer occurs. |
2202 | * | 2240 | * |
@@ -2206,7 +2244,8 @@ static void compute_probabilities (uint32_t peer_idx) | |||
2206 | * | 2244 | * |
2207 | * @return the number of occurrences | 2245 | * @return the number of occurrences |
2208 | */ | 2246 | */ |
2209 | static uint32_t count_peer_in_views_2 (uint32_t peer_idx) | 2247 | static uint32_t |
2248 | count_peer_in_views_2 (uint32_t peer_idx) | ||
2210 | { | 2249 | { |
2211 | uint32_t i, j; | 2250 | uint32_t i, j; |
2212 | uint32_t count = 0; | 2251 | uint32_t count = 0; |
@@ -2228,7 +2267,9 @@ static uint32_t count_peer_in_views_2 (uint32_t peer_idx) | |||
2228 | return count; | 2267 | return count; |
2229 | } | 2268 | } |
2230 | 2269 | ||
2231 | static uint32_t cumulated_view_sizes () | 2270 | |
2271 | static uint32_t | ||
2272 | cumulated_view_sizes () | ||
2232 | { | 2273 | { |
2233 | uint32_t i; | 2274 | uint32_t i; |
2234 | 2275 | ||
@@ -2240,7 +2281,9 @@ static uint32_t cumulated_view_sizes () | |||
2240 | return view_sizes; | 2281 | return view_sizes; |
2241 | } | 2282 | } |
2242 | 2283 | ||
2243 | static void count_peer_in_views (uint32_t *count_peers) | 2284 | |
2285 | static void | ||
2286 | count_peer_in_views (uint32_t *count_peers) | ||
2244 | { | 2287 | { |
2245 | uint32_t i, j; | 2288 | uint32_t i, j; |
2246 | 2289 | ||
@@ -2258,7 +2301,9 @@ static void count_peer_in_views (uint32_t *count_peers) | |||
2258 | } | 2301 | } |
2259 | } | 2302 | } |
2260 | 2303 | ||
2261 | void compute_diversity () | 2304 | |
2305 | void | ||
2306 | compute_diversity () | ||
2262 | { | 2307 | { |
2263 | uint32_t i; | 2308 | uint32_t i; |
2264 | /* ith entry represents the numer of occurrences in other peer's views */ | 2309 | /* ith entry represents the numer of occurrences in other peer's views */ |
@@ -2301,7 +2346,9 @@ void compute_diversity () | |||
2301 | GNUNET_free (deviation); | 2346 | GNUNET_free (deviation); |
2302 | } | 2347 | } |
2303 | 2348 | ||
2304 | void print_view_sizes () | 2349 | |
2350 | void | ||
2351 | print_view_sizes () | ||
2305 | { | 2352 | { |
2306 | uint32_t i; | 2353 | uint32_t i; |
2307 | 2354 | ||
@@ -2315,15 +2362,19 @@ void print_view_sizes () | |||
2315 | } | 2362 | } |
2316 | } | 2363 | } |
2317 | 2364 | ||
2318 | void all_views_updated_cb () | 2365 | |
2366 | void | ||
2367 | all_views_updated_cb () | ||
2319 | { | 2368 | { |
2320 | compute_diversity (); | 2369 | compute_diversity (); |
2321 | print_view_sizes (); | 2370 | print_view_sizes (); |
2322 | } | 2371 | } |
2323 | 2372 | ||
2324 | void view_update_cb (void *cls, | 2373 | |
2325 | uint64_t view_size, | 2374 | void |
2326 | const struct GNUNET_PeerIdentity *peers) | 2375 | view_update_cb (void *cls, |
2376 | uint64_t view_size, | ||
2377 | const struct GNUNET_PeerIdentity *peers) | ||
2327 | { | 2378 | { |
2328 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2379 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2329 | "View was updated (%" PRIu64 ")\n", view_size); | 2380 | "View was updated (%" PRIu64 ")\n", view_size); |
@@ -2372,6 +2423,7 @@ void view_update_cb (void *cls, | |||
2372 | all_views_updated_cb (); | 2423 | all_views_updated_cb (); |
2373 | } | 2424 | } |
2374 | 2425 | ||
2426 | |||
2375 | static void | 2427 | static void |
2376 | pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) | 2428 | pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) |
2377 | { | 2429 | { |
@@ -2380,7 +2432,9 @@ pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) | |||
2380 | GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer); | 2432 | GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer); |
2381 | } | 2433 | } |
2382 | 2434 | ||
2383 | void write_final_stats (void) | 2435 | |
2436 | void | ||
2437 | write_final_stats (void) | ||
2384 | { | 2438 | { |
2385 | uint32_t i; | 2439 | uint32_t i; |
2386 | 2440 | ||
@@ -2416,6 +2470,7 @@ void write_final_stats (void) | |||
2416 | } | 2470 | } |
2417 | } | 2471 | } |
2418 | 2472 | ||
2473 | |||
2419 | /** | 2474 | /** |
2420 | * Continuation called by #GNUNET_STATISTICS_get() functions. | 2475 | * Continuation called by #GNUNET_STATISTICS_get() functions. |
2421 | * | 2476 | * |
@@ -2448,7 +2503,7 @@ post_test_shutdown_ready_cb (void *cls, | |||
2448 | GNUNET_break (0); | 2503 | GNUNET_break (0); |
2449 | } | 2504 | } |
2450 | 2505 | ||
2451 | if ((NULL != rps_peer->stat_op)&& | 2506 | if ((NULL != rps_peer->stat_op) && |
2452 | (GNUNET_YES == check_statistics_collect_completed_single_peer ( | 2507 | (GNUNET_YES == check_statistics_collect_completed_single_peer ( |
2453 | rps_peer)) ) | 2508 | rps_peer)) ) |
2454 | { | 2509 | { |
@@ -2470,6 +2525,7 @@ post_test_shutdown_ready_cb (void *cls, | |||
2470 | } | 2525 | } |
2471 | } | 2526 | } |
2472 | 2527 | ||
2528 | |||
2473 | /** | 2529 | /** |
2474 | * @brief Converts string representation to the corresponding #STAT_TYPE enum. | 2530 | * @brief Converts string representation to the corresponding #STAT_TYPE enum. |
2475 | * | 2531 | * |
@@ -2477,7 +2533,8 @@ post_test_shutdown_ready_cb (void *cls, | |||
2477 | * | 2533 | * |
2478 | * @return corresponding enum | 2534 | * @return corresponding enum |
2479 | */ | 2535 | */ |
2480 | enum STAT_TYPE stat_str_2_type (const char *stat_str) | 2536 | enum STAT_TYPE |
2537 | stat_str_2_type (const char *stat_str) | ||
2481 | { | 2538 | { |
2482 | if (0 == strncmp ("# rounds blocked - no pull replies", stat_str, strlen ( | 2539 | if (0 == strncmp ("# rounds blocked - no pull replies", stat_str, strlen ( |
2483 | "# rounds blocked - no pull replies"))) | 2540 | "# rounds blocked - no pull replies"))) |
@@ -2571,7 +2628,8 @@ enum STAT_TYPE stat_str_2_type (const char *stat_str) | |||
2571 | * | 2628 | * |
2572 | * @return string representation that matches statistics value | 2629 | * @return string representation that matches statistics value |
2573 | */ | 2630 | */ |
2574 | char*stat_type_2_str (enum STAT_TYPE stat_type) | 2631 | char* |
2632 | stat_type_2_str (enum STAT_TYPE stat_type) | ||
2575 | { | 2633 | { |
2576 | switch (stat_type) | 2634 | switch (stat_type) |
2577 | { | 2635 | { |
@@ -2630,6 +2688,7 @@ char*stat_type_2_str (enum STAT_TYPE stat_type) | |||
2630 | } | 2688 | } |
2631 | } | 2689 | } |
2632 | 2690 | ||
2691 | |||
2633 | /** | 2692 | /** |
2634 | * Callback function to process statistic values. | 2693 | * Callback function to process statistic values. |
2635 | * | 2694 | * |
@@ -2735,7 +2794,9 @@ stat_iterator (void *cls, | |||
2735 | return GNUNET_OK; | 2794 | return GNUNET_OK; |
2736 | } | 2795 | } |
2737 | 2796 | ||
2738 | void post_profiler (struct RPSPeer *rps_peer) | 2797 | |
2798 | void | ||
2799 | post_profiler (struct RPSPeer *rps_peer) | ||
2739 | { | 2800 | { |
2740 | if (COLLECT_STATISTICS != cur_test_run.have_collect_statistics) | 2801 | if (COLLECT_STATISTICS != cur_test_run.have_collect_statistics) |
2741 | { | 2802 | { |
@@ -2808,7 +2869,7 @@ run (void *cls, | |||
2808 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n"); | 2869 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n"); |
2809 | 2870 | ||
2810 | /* Check whether we timed out */ | 2871 | /* Check whether we timed out */ |
2811 | if ((n_peers != num_peers)|| | 2872 | if ((n_peers != num_peers) || |
2812 | (NULL == peers) || | 2873 | (NULL == peers) || |
2813 | (0 == links_succeeded) ) | 2874 | (0 == links_succeeded) ) |
2814 | { | 2875 | { |