diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-31 13:03:48 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-31 13:03:48 +0100 |
commit | 7e3cf5f461eb4fbb7581672bf0835da07c378136 (patch) | |
tree | bdc3874b7894242b095b892f1ed3e81a4d4f06c0 /src/rps/gnunet-rps-profiler.c | |
parent | 01b480d6d026e0c537dc284a7e7df2c0320a3528 (diff) | |
download | gnunet-7e3cf5f461eb4fbb7581672bf0835da07c378136.tar.gz gnunet-7e3cf5f461eb4fbb7581672bf0835da07c378136.zip |
tighten formatting rules
Diffstat (limited to 'src/rps/gnunet-rps-profiler.c')
-rw-r--r-- | src/rps/gnunet-rps-profiler.c | 122 |
1 files changed, 86 insertions, 36 deletions
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c index 03b96f264..af43a0fa1 100644 --- a/src/rps/gnunet-rps-profiler.c +++ b/src/rps/gnunet-rps-profiler.c | |||
@@ -160,7 +160,8 @@ struct STATcls | |||
160 | * | 160 | * |
161 | * @return corresponding enum | 161 | * @return corresponding enum |
162 | */ | 162 | */ |
163 | enum STAT_TYPE stat_str_2_type (const char *stat_str) | 163 | enum STAT_TYPE |
164 | stat_str_2_type (const char *stat_str) | ||
164 | { | 165 | { |
165 | if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_NO_PULL], | 166 | if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_NO_PULL], |
166 | stat_str, | 167 | stat_str, |
@@ -890,9 +891,7 @@ tofile_ (const char *file_name, const char *line) | |||
890 | "Failed to write string to buffer (size: %i)\n", | 891 | "Failed to write string to buffer (size: %i)\n", |
891 | size); | 892 | size); |
892 | return; | 893 | return; |
893 | } */ | 894 | } */size = strlen (line) * sizeof(char); |
894 | |||
895 | size = strlen (line) * sizeof(char); | ||
896 | 895 | ||
897 | size2 = GNUNET_DISK_file_write (f, line, size); | 896 | size2 = GNUNET_DISK_file_write (f, line, size); |
898 | if (size != size2) | 897 | if (size != size2) |
@@ -916,6 +915,7 @@ tofile_ (const char *file_name, const char *line) | |||
916 | } | 915 | } |
917 | } | 916 | } |
918 | 917 | ||
918 | |||
919 | /** | 919 | /** |
920 | * This function is used to facilitate writing important information to disk | 920 | * This function is used to facilitate writing important information to disk |
921 | */ | 921 | */ |
@@ -1000,7 +1000,8 @@ make_oplist_entry () | |||
1000 | * @return #GNUNET_YES if so | 1000 | * @return #GNUNET_YES if so |
1001 | * #GNUNET_NO otherwise | 1001 | * #GNUNET_NO otherwise |
1002 | */ | 1002 | */ |
1003 | static int check_statistics_collect_completed_single_peer ( | 1003 | static int |
1004 | check_statistics_collect_completed_single_peer ( | ||
1004 | const struct RPSPeer *rps_peer) | 1005 | const struct RPSPeer *rps_peer) |
1005 | { | 1006 | { |
1006 | if (cur_test_run.stat_collect_flags != | 1007 | if (cur_test_run.stat_collect_flags != |
@@ -1011,6 +1012,8 @@ static int check_statistics_collect_completed_single_peer ( | |||
1011 | } | 1012 | } |
1012 | return GNUNET_YES; | 1013 | return GNUNET_YES; |
1013 | } | 1014 | } |
1015 | |||
1016 | |||
1014 | /** | 1017 | /** |
1015 | * @brief Checks if all peers already received their statistics value from the | 1018 | * @brief Checks if all peers already received their statistics value from the |
1016 | * statistics service. | 1019 | * statistics service. |
@@ -1018,7 +1021,8 @@ static int check_statistics_collect_completed_single_peer ( | |||
1018 | * @return #GNUNET_YES if so | 1021 | * @return #GNUNET_YES if so |
1019 | * #GNUNET_NO otherwise | 1022 | * #GNUNET_NO otherwise |
1020 | */ | 1023 | */ |
1021 | static int check_statistics_collect_completed () | 1024 | static int |
1025 | check_statistics_collect_completed () | ||
1022 | { | 1026 | { |
1023 | uint32_t i; | 1027 | uint32_t i; |
1024 | 1028 | ||
@@ -1039,6 +1043,7 @@ static int check_statistics_collect_completed () | |||
1039 | return GNUNET_YES; | 1043 | return GNUNET_YES; |
1040 | } | 1044 | } |
1041 | 1045 | ||
1046 | |||
1042 | static void | 1047 | static void |
1043 | rps_disconnect_adapter (void *cls, | 1048 | rps_disconnect_adapter (void *cls, |
1044 | void *op_result); | 1049 | void *op_result); |
@@ -1059,6 +1064,7 @@ cancel_pending_req (struct PendingRequest *pending_req) | |||
1059 | GNUNET_free (pending_req); | 1064 | GNUNET_free (pending_req); |
1060 | } | 1065 | } |
1061 | 1066 | ||
1067 | |||
1062 | static void | 1068 | static void |
1063 | cancel_request (struct PendingReply *pending_rep) | 1069 | cancel_request (struct PendingReply *pending_rep) |
1064 | { | 1070 | { |
@@ -1078,6 +1084,7 @@ cancel_request (struct PendingReply *pending_rep) | |||
1078 | pending_rep = NULL; | 1084 | pending_rep = NULL; |
1079 | } | 1085 | } |
1080 | 1086 | ||
1087 | |||
1081 | void | 1088 | void |
1082 | clean_peer (unsigned peer_index) | 1089 | clean_peer (unsigned peer_index) |
1083 | { | 1090 | { |
@@ -1111,6 +1118,7 @@ clean_peer (unsigned peer_index) | |||
1111 | } | 1118 | } |
1112 | } | 1119 | } |
1113 | 1120 | ||
1121 | |||
1114 | /** | 1122 | /** |
1115 | * Task run on timeout to shut everything down. | 1123 | * Task run on timeout to shut everything down. |
1116 | */ | 1124 | */ |
@@ -1158,6 +1166,7 @@ shutdown_op (void *cls) | |||
1158 | close_all_files (); | 1166 | close_all_files (); |
1159 | } | 1167 | } |
1160 | 1168 | ||
1169 | |||
1161 | static void | 1170 | static void |
1162 | trigger_shutdown (void *cls) | 1171 | trigger_shutdown (void *cls) |
1163 | { | 1172 | { |
@@ -1209,7 +1218,7 @@ post_test_op (void *cls) | |||
1209 | } | 1218 | } |
1210 | } | 1219 | } |
1211 | /* If we do not collect statistics, shut down directly */ | 1220 | /* If we do not collect statistics, shut down directly */ |
1212 | if ((NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics)|| | 1221 | if ((NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics) || |
1213 | (GNUNET_YES == check_statistics_collect_completed ()) ) | 1222 | (GNUNET_YES == check_statistics_collect_completed ()) ) |
1214 | { | 1223 | { |
1215 | GNUNET_SCHEDULER_cancel (shutdown_task); | 1224 | GNUNET_SCHEDULER_cancel (shutdown_task); |
@@ -1255,12 +1264,12 @@ info_cb (void *cb_cls, | |||
1255 | 1264 | ||
1256 | (void) op; | 1265 | (void) op; |
1257 | 1266 | ||
1258 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1267 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1259 | { | 1268 | { |
1260 | return; | 1269 | return; |
1261 | } | 1270 | } |
1262 | 1271 | ||
1263 | if ((NULL == pinfo)||(NULL != emsg)) | 1272 | if ((NULL == pinfo) || (NULL != emsg)) |
1264 | { | 1273 | { |
1265 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg); | 1274 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg); |
1266 | GNUNET_TESTBED_operation_done (entry->op); | 1275 | GNUNET_TESTBED_operation_done (entry->op); |
@@ -1309,7 +1318,7 @@ rps_connect_complete_cb (void *cls, | |||
1309 | struct RPSPeer *rps_peer = cls; | 1318 | struct RPSPeer *rps_peer = cls; |
1310 | struct GNUNET_RPS_Handle *rps = ca_result; | 1319 | struct GNUNET_RPS_Handle *rps = ca_result; |
1311 | 1320 | ||
1312 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1321 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1313 | { | 1322 | { |
1314 | return; | 1323 | return; |
1315 | } | 1324 | } |
@@ -1361,6 +1370,7 @@ rps_connect_adapter (void *cls, | |||
1361 | return h; | 1370 | return h; |
1362 | } | 1371 | } |
1363 | 1372 | ||
1373 | |||
1364 | /** | 1374 | /** |
1365 | * Called to open a connection to the peer's statistics | 1375 | * Called to open a connection to the peer's statistics |
1366 | * | 1376 | * |
@@ -1380,6 +1390,7 @@ stat_connect_adapter (void *cls, | |||
1380 | return peer->stats_h; | 1390 | return peer->stats_h; |
1381 | } | 1391 | } |
1382 | 1392 | ||
1393 | |||
1383 | /** | 1394 | /** |
1384 | * Called to disconnect from peer's statistics service | 1395 | * Called to disconnect from peer's statistics service |
1385 | * | 1396 | * |
@@ -1401,6 +1412,7 @@ stat_disconnect_adapter (void *cls, void *op_result) | |||
1401 | peer->stats_h = NULL; | 1412 | peer->stats_h = NULL; |
1402 | } | 1413 | } |
1403 | 1414 | ||
1415 | |||
1404 | /** | 1416 | /** |
1405 | * Called after successfully opening a connection to a peer's statistics | 1417 | * Called after successfully opening a connection to a peer's statistics |
1406 | * service; we register statistics monitoring for CORE and NSE here. | 1418 | * service; we register statistics monitoring for CORE and NSE here. |
@@ -1551,7 +1563,7 @@ request_peers (void *cls) | |||
1551 | rps_peer->pending_req_tail, | 1563 | rps_peer->pending_req_tail, |
1552 | pending_req); | 1564 | pending_req); |
1553 | rps_peer->num_pending_reqs--; | 1565 | rps_peer->num_pending_reqs--; |
1554 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1566 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1555 | return; | 1567 | return; |
1556 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1568 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1557 | "Requesting one peer\n"); | 1569 | "Requesting one peer\n"); |
@@ -1604,6 +1616,7 @@ schedule_missing_requests (struct RPSPeer *rps_peer) | |||
1604 | } | 1616 | } |
1605 | } | 1617 | } |
1606 | 1618 | ||
1619 | |||
1607 | void | 1620 | void |
1608 | cancel_pending_req_rep (struct RPSPeer *rps_peer) | 1621 | cancel_pending_req_rep (struct RPSPeer *rps_peer) |
1609 | { | 1622 | { |
@@ -1617,6 +1630,7 @@ cancel_pending_req_rep (struct RPSPeer *rps_peer) | |||
1617 | GNUNET_assert (0 == rps_peer->num_pending_reps); | 1630 | GNUNET_assert (0 == rps_peer->num_pending_reps); |
1618 | } | 1631 | } |
1619 | 1632 | ||
1633 | |||
1620 | /*********************************** | 1634 | /*********************************** |
1621 | * MALICIOUS | 1635 | * MALICIOUS |
1622 | ***********************************/ | 1636 | ***********************************/ |
@@ -1624,7 +1638,8 @@ cancel_pending_req_rep (struct RPSPeer *rps_peer) | |||
1624 | /** | 1638 | /** |
1625 | * Initialise only non-mal RPSPeers | 1639 | * Initialise only non-mal RPSPeers |
1626 | */ | 1640 | */ |
1627 | static void mal_init_peer (struct RPSPeer *rps_peer) | 1641 | static void |
1642 | mal_init_peer (struct RPSPeer *rps_peer) | ||
1628 | { | 1643 | { |
1629 | if (rps_peer->index >= round (portion * num_peers)) | 1644 | if (rps_peer->index >= round (portion * num_peers)) |
1630 | rps_peer->num_ids_to_request = 1; | 1645 | rps_peer->num_ids_to_request = 1; |
@@ -1664,12 +1679,13 @@ mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) | |||
1664 | #endif /* ENABLE_MALICIOUS */ | 1679 | #endif /* ENABLE_MALICIOUS */ |
1665 | } | 1680 | } |
1666 | 1681 | ||
1682 | |||
1667 | static void | 1683 | static void |
1668 | mal_cb (struct RPSPeer *rps_peer) | 1684 | mal_cb (struct RPSPeer *rps_peer) |
1669 | { | 1685 | { |
1670 | uint32_t num_mal_peers; | 1686 | uint32_t num_mal_peers; |
1671 | 1687 | ||
1672 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1688 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1673 | { | 1689 | { |
1674 | return; | 1690 | return; |
1675 | } | 1691 | } |
@@ -1690,6 +1706,7 @@ mal_cb (struct RPSPeer *rps_peer) | |||
1690 | #endif /* ENABLE_MALICIOUS */ | 1706 | #endif /* ENABLE_MALICIOUS */ |
1691 | } | 1707 | } |
1692 | 1708 | ||
1709 | |||
1693 | /*********************************** | 1710 | /*********************************** |
1694 | * CHURN | 1711 | * CHURN |
1695 | ***********************************/ | 1712 | ***********************************/ |
@@ -1711,13 +1728,13 @@ churn (void *cls); | |||
1711 | static void | 1728 | static void |
1712 | churn_test_cb (struct RPSPeer *rps_peer) | 1729 | churn_test_cb (struct RPSPeer *rps_peer) |
1713 | { | 1730 | { |
1714 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1731 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1715 | { | 1732 | { |
1716 | return; | 1733 | return; |
1717 | } | 1734 | } |
1718 | 1735 | ||
1719 | /* Start churn */ | 1736 | /* Start churn */ |
1720 | if ((HAVE_CHURN == cur_test_run.have_churn)&&(NULL == churn_task)) | 1737 | if ((HAVE_CHURN == cur_test_run.have_churn) && (NULL == churn_task)) |
1721 | { | 1738 | { |
1722 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1739 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1723 | "Starting churn task\n"); | 1740 | "Starting churn task\n"); |
@@ -1735,6 +1752,7 @@ churn_test_cb (struct RPSPeer *rps_peer) | |||
1735 | schedule_missing_requests (rps_peer); | 1752 | schedule_missing_requests (rps_peer); |
1736 | } | 1753 | } |
1737 | 1754 | ||
1755 | |||
1738 | /*********************************** | 1756 | /*********************************** |
1739 | * PROFILER | 1757 | * PROFILER |
1740 | ***********************************/ | 1758 | ***********************************/ |
@@ -1756,7 +1774,7 @@ churn_cb (void *cls, | |||
1756 | 1774 | ||
1757 | (void) op; | 1775 | (void) op; |
1758 | 1776 | ||
1759 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1777 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1760 | { | 1778 | { |
1761 | return; | 1779 | return; |
1762 | } | 1780 | } |
@@ -1828,6 +1846,7 @@ churn_cb (void *cls, | |||
1828 | // run_round (); | 1846 | // run_round (); |
1829 | } | 1847 | } |
1830 | 1848 | ||
1849 | |||
1831 | /** | 1850 | /** |
1832 | * @brief Set the rps-service up or down for a specific peer | 1851 | * @brief Set the rps-service up or down for a specific peer |
1833 | * | 1852 | * |
@@ -1895,7 +1914,7 @@ churn (void *cls) | |||
1895 | 1914 | ||
1896 | (void) cls; | 1915 | (void) cls; |
1897 | 1916 | ||
1898 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 1917 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
1899 | { | 1918 | { |
1900 | return; | 1919 | return; |
1901 | } | 1920 | } |
@@ -1956,7 +1975,8 @@ churn (void *cls) | |||
1956 | /** | 1975 | /** |
1957 | * Initialise given RPSPeer | 1976 | * Initialise given RPSPeer |
1958 | */ | 1977 | */ |
1959 | static void profiler_init_peer (struct RPSPeer *rps_peer) | 1978 | static void |
1979 | profiler_init_peer (struct RPSPeer *rps_peer) | ||
1960 | { | 1980 | { |
1961 | rps_peer->num_ids_to_request = cur_test_run.num_requests; | 1981 | rps_peer->num_ids_to_request = cur_test_run.num_requests; |
1962 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "peer shall request %i peers\n", | 1982 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "peer shall request %i peers\n", |
@@ -2111,13 +2131,13 @@ profiler_reply_handle_info (void *cls, | |||
2111 | static void | 2131 | static void |
2112 | profiler_cb (struct RPSPeer *rps_peer) | 2132 | profiler_cb (struct RPSPeer *rps_peer) |
2113 | { | 2133 | { |
2114 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) | 2134 | if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) |
2115 | { | 2135 | { |
2116 | return; | 2136 | return; |
2117 | } | 2137 | } |
2118 | 2138 | ||
2119 | /* Start churn */ | 2139 | /* Start churn */ |
2120 | if ((HAVE_CHURN == cur_test_run.have_churn)&&(NULL == churn_task)) | 2140 | if ((HAVE_CHURN == cur_test_run.have_churn) && (NULL == churn_task)) |
2121 | { | 2141 | { |
2122 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2142 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2123 | "Starting churn task\n"); | 2143 | "Starting churn task\n"); |
@@ -2139,6 +2159,7 @@ profiler_cb (struct RPSPeer *rps_peer) | |||
2139 | schedule_missing_requests (rps_peer); | 2159 | schedule_missing_requests (rps_peer); |
2140 | } | 2160 | } |
2141 | 2161 | ||
2162 | |||
2142 | /** | 2163 | /** |
2143 | * Function called from #profiler_eval with a filename. | 2164 | * Function called from #profiler_eval with a filename. |
2144 | * | 2165 | * |
@@ -2175,6 +2196,7 @@ file_name_cb (void *cls, const char *filename) | |||
2175 | return GNUNET_OK; | 2196 | return GNUNET_OK; |
2176 | } | 2197 | } |
2177 | 2198 | ||
2199 | |||
2178 | /** | 2200 | /** |
2179 | * This is run after the test finished. | 2201 | * This is run after the test finished. |
2180 | * | 2202 | * |
@@ -2202,7 +2224,8 @@ profiler_eval (void) | |||
2202 | * | 2224 | * |
2203 | * @return | 2225 | * @return |
2204 | */ | 2226 | */ |
2205 | static int is_in_view (uint32_t a, uint32_t b) | 2227 | static int |
2228 | is_in_view (uint32_t a, uint32_t b) | ||
2206 | { | 2229 | { |
2207 | uint32_t i; | 2230 | uint32_t i; |
2208 | 2231 | ||
@@ -2218,7 +2241,9 @@ static int is_in_view (uint32_t a, uint32_t b) | |||
2218 | return GNUNET_NO; | 2241 | return GNUNET_NO; |
2219 | } | 2242 | } |
2220 | 2243 | ||
2221 | static uint32_t get_idx_of_pid (const struct GNUNET_PeerIdentity *pid) | 2244 | |
2245 | static uint32_t | ||
2246 | get_idx_of_pid (const struct GNUNET_PeerIdentity *pid) | ||
2222 | { | 2247 | { |
2223 | uint32_t i; | 2248 | uint32_t i; |
2224 | 2249 | ||
@@ -2238,6 +2263,7 @@ static uint32_t get_idx_of_pid (const struct GNUNET_PeerIdentity *pid) | |||
2238 | GNUNET_assert (0); | 2263 | GNUNET_assert (0); |
2239 | } | 2264 | } |
2240 | 2265 | ||
2266 | |||
2241 | /** | 2267 | /** |
2242 | * @brief Counts number of peers in view of a that have b in their view | 2268 | * @brief Counts number of peers in view of a that have b in their view |
2243 | * | 2269 | * |
@@ -2246,7 +2272,8 @@ static uint32_t get_idx_of_pid (const struct GNUNET_PeerIdentity *pid) | |||
2246 | * | 2272 | * |
2247 | * @return | 2273 | * @return |
2248 | */ | 2274 | */ |
2249 | static uint32_t count_containing_views (uint32_t a, uint32_t b) | 2275 | static uint32_t |
2276 | count_containing_views (uint32_t a, uint32_t b) | ||
2250 | { | 2277 | { |
2251 | uint32_t i; | 2278 | uint32_t i; |
2252 | uint32_t peer_idx; | 2279 | uint32_t peer_idx; |
@@ -2263,13 +2290,15 @@ static uint32_t count_containing_views (uint32_t a, uint32_t b) | |||
2263 | return count; | 2290 | return count; |
2264 | } | 2291 | } |
2265 | 2292 | ||
2293 | |||
2266 | /** | 2294 | /** |
2267 | * @brief Computes the probability for each other peer to be selected by the | 2295 | * @brief Computes the probability for each other peer to be selected by the |
2268 | * sampling process based on the views of all peers | 2296 | * sampling process based on the views of all peers |
2269 | * | 2297 | * |
2270 | * @param peer_idx index of the peer that is about to sample | 2298 | * @param peer_idx index of the peer that is about to sample |
2271 | */ | 2299 | */ |
2272 | static void compute_probabilities (uint32_t peer_idx) | 2300 | static void |
2301 | compute_probabilities (uint32_t peer_idx) | ||
2273 | { | 2302 | { |
2274 | // double probs[num_peers] = { 0 }; | 2303 | // double probs[num_peers] = { 0 }; |
2275 | double probs[num_peers]; | 2304 | double probs[num_peers]; |
@@ -2427,6 +2456,7 @@ static void compute_probabilities (uint32_t peer_idx) | |||
2427 | GNUNET_free (probs_as_str); | 2456 | GNUNET_free (probs_as_str); |
2428 | } | 2457 | } |
2429 | 2458 | ||
2459 | |||
2430 | /** | 2460 | /** |
2431 | * @brief This counts the number of peers in which views a given peer occurs. | 2461 | * @brief This counts the number of peers in which views a given peer occurs. |
2432 | * | 2462 | * |
@@ -2436,7 +2466,8 @@ static void compute_probabilities (uint32_t peer_idx) | |||
2436 | * | 2466 | * |
2437 | * @return the number of occurrences | 2467 | * @return the number of occurrences |
2438 | */ | 2468 | */ |
2439 | static uint32_t count_peer_in_views_2 (uint32_t peer_idx) | 2469 | static uint32_t |
2470 | count_peer_in_views_2 (uint32_t peer_idx) | ||
2440 | { | 2471 | { |
2441 | uint32_t i, j; | 2472 | uint32_t i, j; |
2442 | uint32_t count = 0; | 2473 | uint32_t count = 0; |
@@ -2458,7 +2489,9 @@ static uint32_t count_peer_in_views_2 (uint32_t peer_idx) | |||
2458 | return count; | 2489 | return count; |
2459 | } | 2490 | } |
2460 | 2491 | ||
2461 | static uint32_t cumulated_view_sizes () | 2492 | |
2493 | static uint32_t | ||
2494 | cumulated_view_sizes () | ||
2462 | { | 2495 | { |
2463 | uint32_t i; | 2496 | uint32_t i; |
2464 | 2497 | ||
@@ -2470,7 +2503,9 @@ static uint32_t cumulated_view_sizes () | |||
2470 | return view_sizes; | 2503 | return view_sizes; |
2471 | } | 2504 | } |
2472 | 2505 | ||
2473 | static void count_peer_in_views (uint32_t *count_peers) | 2506 | |
2507 | static void | ||
2508 | count_peer_in_views (uint32_t *count_peers) | ||
2474 | { | 2509 | { |
2475 | uint32_t i, j; | 2510 | uint32_t i, j; |
2476 | 2511 | ||
@@ -2488,7 +2523,9 @@ static void count_peer_in_views (uint32_t *count_peers) | |||
2488 | } | 2523 | } |
2489 | } | 2524 | } |
2490 | 2525 | ||
2491 | void compute_diversity () | 2526 | |
2527 | void | ||
2528 | compute_diversity () | ||
2492 | { | 2529 | { |
2493 | uint32_t i; | 2530 | uint32_t i; |
2494 | /* ith entry represents the numer of occurrences in other peer's views */ | 2531 | /* ith entry represents the numer of occurrences in other peer's views */ |
@@ -2531,7 +2568,9 @@ void compute_diversity () | |||
2531 | GNUNET_free (deviation); | 2568 | GNUNET_free (deviation); |
2532 | } | 2569 | } |
2533 | 2570 | ||
2534 | void print_view_sizes () | 2571 | |
2572 | void | ||
2573 | print_view_sizes () | ||
2535 | { | 2574 | { |
2536 | uint32_t i; | 2575 | uint32_t i; |
2537 | 2576 | ||
@@ -2545,15 +2584,19 @@ void print_view_sizes () | |||
2545 | } | 2584 | } |
2546 | } | 2585 | } |
2547 | 2586 | ||
2548 | void all_views_updated_cb () | 2587 | |
2588 | void | ||
2589 | all_views_updated_cb () | ||
2549 | { | 2590 | { |
2550 | compute_diversity (); | 2591 | compute_diversity (); |
2551 | print_view_sizes (); | 2592 | print_view_sizes (); |
2552 | } | 2593 | } |
2553 | 2594 | ||
2554 | void view_update_cb (void *cls, | 2595 | |
2555 | uint64_t view_size, | 2596 | void |
2556 | const struct GNUNET_PeerIdentity *peers) | 2597 | view_update_cb (void *cls, |
2598 | uint64_t view_size, | ||
2599 | const struct GNUNET_PeerIdentity *peers) | ||
2557 | { | 2600 | { |
2558 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2601 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2559 | "View was updated (%" PRIu64 ")\n", view_size); | 2602 | "View was updated (%" PRIu64 ")\n", view_size); |
@@ -2602,6 +2645,7 @@ void view_update_cb (void *cls, | |||
2602 | all_views_updated_cb (); | 2645 | all_views_updated_cb (); |
2603 | } | 2646 | } |
2604 | 2647 | ||
2648 | |||
2605 | static void | 2649 | static void |
2606 | pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) | 2650 | pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) |
2607 | { | 2651 | { |
@@ -2612,7 +2656,9 @@ pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) | |||
2612 | GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer); | 2656 | GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer); |
2613 | } | 2657 | } |
2614 | 2658 | ||
2615 | void write_final_stats (void) | 2659 | |
2660 | void | ||
2661 | write_final_stats (void) | ||
2616 | { | 2662 | { |
2617 | uint64_t sums[STAT_TYPE_MAX] = { 0 }; | 2663 | uint64_t sums[STAT_TYPE_MAX] = { 0 }; |
2618 | 2664 | ||
@@ -2732,6 +2778,7 @@ void write_final_stats (void) | |||
2732 | sums[STAT_TYPE_VIEW_SIZE_AIM]); | 2778 | sums[STAT_TYPE_VIEW_SIZE_AIM]); |
2733 | } | 2779 | } |
2734 | 2780 | ||
2781 | |||
2735 | /** | 2782 | /** |
2736 | * Continuation called by #GNUNET_STATISTICS_get() functions. | 2783 | * Continuation called by #GNUNET_STATISTICS_get() functions. |
2737 | * | 2784 | * |
@@ -2766,7 +2813,7 @@ post_test_shutdown_ready_cb (void *cls, | |||
2766 | return; | 2813 | return; |
2767 | } | 2814 | } |
2768 | 2815 | ||
2769 | if ((NULL != rps_peer->stat_op)&& | 2816 | if ((NULL != rps_peer->stat_op) && |
2770 | (GNUNET_YES == check_statistics_collect_completed_single_peer ( | 2817 | (GNUNET_YES == check_statistics_collect_completed_single_peer ( |
2771 | rps_peer)) ) | 2818 | rps_peer)) ) |
2772 | { | 2819 | { |
@@ -2788,6 +2835,7 @@ post_test_shutdown_ready_cb (void *cls, | |||
2788 | } | 2835 | } |
2789 | } | 2836 | } |
2790 | 2837 | ||
2838 | |||
2791 | /** | 2839 | /** |
2792 | * Callback function to process statistic values. | 2840 | * Callback function to process statistic values. |
2793 | * | 2841 | * |
@@ -2907,7 +2955,7 @@ test_run (void *cls, | |||
2907 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n"); | 2955 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n"); |
2908 | 2956 | ||
2909 | /* Check whether we timed out */ | 2957 | /* Check whether we timed out */ |
2910 | if ((n_peers != num_peers)|| | 2958 | if ((n_peers != num_peers) || |
2911 | (NULL == peers) || | 2959 | (NULL == peers) || |
2912 | (0 == links_succeeded) ) | 2960 | (0 == links_succeeded) ) |
2913 | { | 2961 | { |
@@ -3127,6 +3175,7 @@ run (void *cls, | |||
3127 | NULL); | 3175 | NULL); |
3128 | } | 3176 | } |
3129 | 3177 | ||
3178 | |||
3130 | /** | 3179 | /** |
3131 | * Entry point for the testcase, sets up the testbed. | 3180 | * Entry point for the testcase, sets up the testbed. |
3132 | * | 3181 | * |
@@ -3204,4 +3253,5 @@ main (int argc, char *argv[]) | |||
3204 | return ret_value; | 3253 | return ret_value; |
3205 | } | 3254 | } |
3206 | 3255 | ||
3256 | |||
3207 | /* end of test_rps.c */ | 3257 | /* end of test_rps.c */ |