diff options
author | Nathan S. Evans <evans@in.tum.de> | 2011-02-28 11:06:03 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2011-02-28 11:06:03 +0000 |
commit | 6b5bb22d6a3c40fd15aa4f87b1e520c0723065ff (patch) | |
tree | 2df170b3ba6fdcd3d333ec3f6ba1015dad67a734 /src/testing | |
parent | 9982ecf65db1f4c20e50dabfe355188455b7d8dc (diff) | |
download | gnunet-6b5bb22d6a3c40fd15aa4f87b1e520c0723065ff.tar.gz gnunet-6b5bb22d6a3c40fd15aa4f87b1e520c0723065ff.zip |
code format, fix shutdown bottleneck
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/testing_group.c | 202 |
1 files changed, 117 insertions, 85 deletions
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 5c5f80798..f237ec030 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c | |||
@@ -84,8 +84,8 @@ enum PeerLists | |||
84 | */ | 84 | */ |
85 | typedef unsigned int | 85 | typedef unsigned int |
86 | (*GNUNET_TESTING_ConnectionProcessor)(struct GNUNET_TESTING_PeerGroup * pg, | 86 | (*GNUNET_TESTING_ConnectionProcessor)(struct GNUNET_TESTING_PeerGroup * pg, |
87 | unsigned int first, unsigned int second, enum PeerLists list, | 87 | unsigned int first, unsigned int second, |
88 | unsigned int check); | 88 | enum PeerLists list, unsigned int check); |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * Context for handling churning a peer group | 91 | * Context for handling churning a peer group |
@@ -1105,7 +1105,7 @@ free_meter(struct ProgressMeter *meter) | |||
1105 | */ | 1105 | */ |
1106 | int | 1106 | int |
1107 | GNUNET_TESTING_topology_get(enum GNUNET_TESTING_Topology *topology, | 1107 | GNUNET_TESTING_topology_get(enum GNUNET_TESTING_Topology *topology, |
1108 | const char *topology_string) | 1108 | const char *topology_string) |
1109 | { | 1109 | { |
1110 | /** | 1110 | /** |
1111 | * Strings representing topologies in enum | 1111 | * Strings representing topologies in enum |
@@ -1197,8 +1197,8 @@ GNUNET_TESTING_topology_get(enum GNUNET_TESTING_Topology *topology, | |||
1197 | */ | 1197 | */ |
1198 | int | 1198 | int |
1199 | GNUNET_TESTING_topology_option_get( | 1199 | GNUNET_TESTING_topology_option_get( |
1200 | enum GNUNET_TESTING_TopologyOption *topology_option, | 1200 | enum GNUNET_TESTING_TopologyOption *topology_option, |
1201 | const char *topology_string) | 1201 | const char *topology_string) |
1202 | { | 1202 | { |
1203 | /** | 1203 | /** |
1204 | * Options for connecting a topology as strings. | 1204 | * Options for connecting a topology as strings. |
@@ -1270,7 +1270,7 @@ GNUNET_TESTING_topology_option_get( | |||
1270 | */ | 1270 | */ |
1271 | static void | 1271 | static void |
1272 | update_config(void *cls, const char *section, const char *option, | 1272 | update_config(void *cls, const char *section, const char *option, |
1273 | const char *value) | 1273 | const char *value) |
1274 | { | 1274 | { |
1275 | struct UpdateContext *ctx = cls; | 1275 | struct UpdateContext *ctx = cls; |
1276 | unsigned int ival; | 1276 | unsigned int ival; |
@@ -1356,7 +1356,8 @@ update_config(void *cls, const char *section, const char *option, | |||
1356 | */ | 1356 | */ |
1357 | static struct GNUNET_CONFIGURATION_Handle * | 1357 | static struct GNUNET_CONFIGURATION_Handle * |
1358 | make_config(const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off, | 1358 | make_config(const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off, |
1359 | uint16_t * port, uint32_t * upnum, const char *hostname, uint32_t * fdnum) | 1359 | uint16_t * port, uint32_t * upnum, const char *hostname, |
1360 | uint32_t * fdnum) | ||
1360 | { | 1361 | { |
1361 | struct UpdateContext uc; | 1362 | struct UpdateContext uc; |
1362 | uint16_t orig; | 1363 | uint16_t orig; |
@@ -1450,7 +1451,7 @@ make_config(const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off, | |||
1450 | */ | 1451 | */ |
1451 | static unsigned int | 1452 | static unsigned int |
1452 | remove_connections(struct GNUNET_TESTING_PeerGroup *pg, unsigned int first, | 1453 | remove_connections(struct GNUNET_TESTING_PeerGroup *pg, unsigned int first, |
1453 | unsigned int second, enum PeerLists list, unsigned int check) | 1454 | unsigned int second, enum PeerLists list, unsigned int check) |
1454 | { | 1455 | { |
1455 | int removed; | 1456 | int removed; |
1456 | #if OLD | 1457 | #if OLD |
@@ -1563,7 +1564,7 @@ remove_connections(struct GNUNET_TESTING_PeerGroup *pg, unsigned int first, | |||
1563 | */ | 1564 | */ |
1564 | static unsigned int | 1565 | static unsigned int |
1565 | add_connections(struct GNUNET_TESTING_PeerGroup *pg, unsigned int first, | 1566 | add_connections(struct GNUNET_TESTING_PeerGroup *pg, unsigned int first, |
1566 | unsigned int second, enum PeerLists list, unsigned int check) | 1567 | unsigned int second, enum PeerLists list, unsigned int check) |
1567 | { | 1568 | { |
1568 | int added; | 1569 | int added; |
1569 | int add_first; | 1570 | int add_first; |
@@ -1722,7 +1723,7 @@ add_connections(struct GNUNET_TESTING_PeerGroup *pg, unsigned int first, | |||
1722 | */ | 1723 | */ |
1723 | static unsigned int | 1724 | static unsigned int |
1724 | create_scale_free(struct GNUNET_TESTING_PeerGroup *pg, | 1725 | create_scale_free(struct GNUNET_TESTING_PeerGroup *pg, |
1725 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) | 1726 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) |
1726 | { | 1727 | { |
1727 | 1728 | ||
1728 | unsigned int total_connections; | 1729 | unsigned int total_connections; |
@@ -1796,7 +1797,8 @@ create_scale_free(struct GNUNET_TESTING_PeerGroup *pg, | |||
1796 | */ | 1797 | */ |
1797 | static unsigned int | 1798 | static unsigned int |
1798 | create_small_world_ring(struct GNUNET_TESTING_PeerGroup *pg, | 1799 | create_small_world_ring(struct GNUNET_TESTING_PeerGroup *pg, |
1799 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) | 1800 | GNUNET_TESTING_ConnectionProcessor proc, |
1801 | enum PeerLists list) | ||
1800 | { | 1802 | { |
1801 | unsigned int i, j; | 1803 | unsigned int i, j; |
1802 | int nodeToConnect; | 1804 | int nodeToConnect; |
@@ -1921,7 +1923,8 @@ create_small_world_ring(struct GNUNET_TESTING_PeerGroup *pg, | |||
1921 | */ | 1923 | */ |
1922 | static unsigned int | 1924 | static unsigned int |
1923 | create_nated_internet(struct GNUNET_TESTING_PeerGroup *pg, | 1925 | create_nated_internet(struct GNUNET_TESTING_PeerGroup *pg, |
1924 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) | 1926 | GNUNET_TESTING_ConnectionProcessor proc, |
1927 | enum PeerLists list) | ||
1925 | { | 1928 | { |
1926 | unsigned int outer_count, inner_count; | 1929 | unsigned int outer_count, inner_count; |
1927 | unsigned int cutoff; | 1930 | unsigned int cutoff; |
@@ -1979,7 +1982,8 @@ create_nated_internet(struct GNUNET_TESTING_PeerGroup *pg, | |||
1979 | */ | 1982 | */ |
1980 | static unsigned int | 1983 | static unsigned int |
1981 | create_nated_internet_copy(struct GNUNET_TESTING_PeerGroup *pg, | 1984 | create_nated_internet_copy(struct GNUNET_TESTING_PeerGroup *pg, |
1982 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) | 1985 | GNUNET_TESTING_ConnectionProcessor proc, |
1986 | enum PeerLists list) | ||
1983 | { | 1987 | { |
1984 | unsigned int outer_count, inner_count; | 1988 | unsigned int outer_count, inner_count; |
1985 | unsigned int cutoff; | 1989 | unsigned int cutoff; |
@@ -2055,7 +2059,7 @@ create_nated_internet_copy(struct GNUNET_TESTING_PeerGroup *pg, | |||
2055 | */ | 2059 | */ |
2056 | static unsigned int | 2060 | static unsigned int |
2057 | create_small_world(struct GNUNET_TESTING_PeerGroup *pg, | 2061 | create_small_world(struct GNUNET_TESTING_PeerGroup *pg, |
2058 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) | 2062 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) |
2059 | { | 2063 | { |
2060 | unsigned int i, j, k; | 2064 | unsigned int i, j, k; |
2061 | unsigned int square; | 2065 | unsigned int square; |
@@ -2230,7 +2234,7 @@ create_small_world(struct GNUNET_TESTING_PeerGroup *pg, | |||
2230 | */ | 2234 | */ |
2231 | static unsigned int | 2235 | static unsigned int |
2232 | create_erdos_renyi(struct GNUNET_TESTING_PeerGroup *pg, | 2236 | create_erdos_renyi(struct GNUNET_TESTING_PeerGroup *pg, |
2233 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) | 2237 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) |
2234 | { | 2238 | { |
2235 | double temp_rand; | 2239 | double temp_rand; |
2236 | unsigned int outer_count; | 2240 | unsigned int outer_count; |
@@ -2293,7 +2297,7 @@ create_erdos_renyi(struct GNUNET_TESTING_PeerGroup *pg, | |||
2293 | */ | 2297 | */ |
2294 | static unsigned int | 2298 | static unsigned int |
2295 | create_2d_torus(struct GNUNET_TESTING_PeerGroup *pg, | 2299 | create_2d_torus(struct GNUNET_TESTING_PeerGroup *pg, |
2296 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) | 2300 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) |
2297 | { | 2301 | { |
2298 | unsigned int i; | 2302 | unsigned int i; |
2299 | unsigned int square; | 2303 | unsigned int square; |
@@ -2387,8 +2391,8 @@ create_2d_torus(struct GNUNET_TESTING_PeerGroup *pg, | |||
2387 | */ | 2391 | */ |
2388 | static unsigned int | 2392 | static unsigned int |
2389 | create_clique(struct GNUNET_TESTING_PeerGroup *pg, | 2393 | create_clique(struct GNUNET_TESTING_PeerGroup *pg, |
2390 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list, | 2394 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list, |
2391 | unsigned int check) | 2395 | unsigned int check) |
2392 | { | 2396 | { |
2393 | unsigned int outer_count; | 2397 | unsigned int outer_count; |
2394 | unsigned int inner_count; | 2398 | unsigned int inner_count; |
@@ -2460,7 +2464,7 @@ unblacklist_iterator (void *cls, | |||
2460 | */ | 2464 | */ |
2461 | static unsigned int | 2465 | static unsigned int |
2462 | copy_allowed(struct GNUNET_TESTING_PeerGroup *pg, | 2466 | copy_allowed(struct GNUNET_TESTING_PeerGroup *pg, |
2463 | GNUNET_TESTING_ConnectionProcessor proc) | 2467 | GNUNET_TESTING_ConnectionProcessor proc) |
2464 | { | 2468 | { |
2465 | struct UnblacklistContext un_ctx; | 2469 | struct UnblacklistContext un_ctx; |
2466 | unsigned int count; | 2470 | unsigned int count; |
@@ -2502,7 +2506,7 @@ copy_allowed(struct GNUNET_TESTING_PeerGroup *pg, | |||
2502 | */ | 2506 | */ |
2503 | static unsigned int | 2507 | static unsigned int |
2504 | create_line(struct GNUNET_TESTING_PeerGroup *pg, | 2508 | create_line(struct GNUNET_TESTING_PeerGroup *pg, |
2505 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) | 2509 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) |
2506 | { | 2510 | { |
2507 | unsigned int count; | 2511 | unsigned int count; |
2508 | int connect_attempts; | 2512 | int connect_attempts; |
@@ -2537,7 +2541,7 @@ create_line(struct GNUNET_TESTING_PeerGroup *pg, | |||
2537 | */ | 2541 | */ |
2538 | static unsigned int | 2542 | static unsigned int |
2539 | create_from_file(struct GNUNET_TESTING_PeerGroup *pg, char *filename, | 2543 | create_from_file(struct GNUNET_TESTING_PeerGroup *pg, char *filename, |
2540 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) | 2544 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) |
2541 | { | 2545 | { |
2542 | int connect_attempts; | 2546 | int connect_attempts; |
2543 | unsigned int first_peer_index; | 2547 | unsigned int first_peer_index; |
@@ -2683,7 +2687,7 @@ create_from_file(struct GNUNET_TESTING_PeerGroup *pg, char *filename, | |||
2683 | */ | 2687 | */ |
2684 | static unsigned int | 2688 | static unsigned int |
2685 | create_ring(struct GNUNET_TESTING_PeerGroup *pg, | 2689 | create_ring(struct GNUNET_TESTING_PeerGroup *pg, |
2686 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) | 2690 | GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) |
2687 | { | 2691 | { |
2688 | unsigned int count; | 2692 | unsigned int count; |
2689 | int connect_attempts; | 2693 | int connect_attempts; |
@@ -2955,7 +2959,7 @@ create_and_copy_friend_files(struct GNUNET_TESTING_PeerGroup *pg) | |||
2955 | */ | 2959 | */ |
2956 | static int | 2960 | static int |
2957 | create_and_copy_blacklist_files(struct GNUNET_TESTING_PeerGroup *pg, | 2961 | create_and_copy_blacklist_files(struct GNUNET_TESTING_PeerGroup *pg, |
2958 | const char *transports) | 2962 | const char *transports) |
2959 | { | 2963 | { |
2960 | FILE *temp_file_handle; | 2964 | FILE *temp_file_handle; |
2961 | unsigned int pg_iter; | 2965 | unsigned int pg_iter; |
@@ -3546,11 +3550,13 @@ static void schedule_send_hellos (void *cls, const struct GNUNET_SCHEDULER_TaskC | |||
3546 | */ | 3550 | */ |
3547 | static void | 3551 | static void |
3548 | internal_connect_notify(void *cls, const struct GNUNET_PeerIdentity *first, | 3552 | internal_connect_notify(void *cls, const struct GNUNET_PeerIdentity *first, |
3549 | const struct GNUNET_PeerIdentity *second, uint32_t distance, | 3553 | const struct GNUNET_PeerIdentity *second, |
3550 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 3554 | uint32_t distance, |
3551 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 3555 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
3552 | struct GNUNET_TESTING_Daemon *first_daemon, | 3556 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
3553 | struct GNUNET_TESTING_Daemon *second_daemon, const char *emsg) | 3557 | struct GNUNET_TESTING_Daemon *first_daemon, |
3558 | struct GNUNET_TESTING_Daemon *second_daemon, | ||
3559 | const char *emsg) | ||
3554 | { | 3560 | { |
3555 | struct ConnectContext *connect_ctx = cls; | 3561 | struct ConnectContext *connect_ctx = cls; |
3556 | struct ConnectTopologyContext *ct_ctx = connect_ctx->ct_ctx; | 3562 | struct ConnectTopologyContext *ct_ctx = connect_ctx->ct_ctx; |
@@ -3771,8 +3777,10 @@ copy_allowed_topology(struct GNUNET_TESTING_PeerGroup *pg) | |||
3771 | */ | 3777 | */ |
3772 | static int | 3778 | static int |
3773 | connect_topology(struct GNUNET_TESTING_PeerGroup *pg, | 3779 | connect_topology(struct GNUNET_TESTING_PeerGroup *pg, |
3774 | struct GNUNET_TIME_Relative connect_timeout, unsigned int connect_attempts, | 3780 | struct GNUNET_TIME_Relative connect_timeout, |
3775 | GNUNET_TESTING_NotifyCompletion notify_callback, void *notify_cls) | 3781 | unsigned int connect_attempts, |
3782 | GNUNET_TESTING_NotifyCompletion notify_callback, | ||
3783 | void *notify_cls) | ||
3776 | { | 3784 | { |
3777 | unsigned int pg_iter; | 3785 | unsigned int pg_iter; |
3778 | unsigned int total; | 3786 | unsigned int total; |
@@ -3855,9 +3863,9 @@ connect_topology(struct GNUNET_TESTING_PeerGroup *pg, | |||
3855 | */ | 3863 | */ |
3856 | unsigned int | 3864 | unsigned int |
3857 | GNUNET_TESTING_create_topology(struct GNUNET_TESTING_PeerGroup *pg, | 3865 | GNUNET_TESTING_create_topology(struct GNUNET_TESTING_PeerGroup *pg, |
3858 | enum GNUNET_TESTING_Topology topology, | 3866 | enum GNUNET_TESTING_Topology topology, |
3859 | enum GNUNET_TESTING_Topology restrict_topology, | 3867 | enum GNUNET_TESTING_Topology restrict_topology, |
3860 | const char *restrict_transports) | 3868 | const char *restrict_transports) |
3861 | { | 3869 | { |
3862 | int ret; | 3870 | int ret; |
3863 | 3871 | ||
@@ -4302,7 +4310,7 @@ dfs_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value) | |||
4302 | */ | 4310 | */ |
4303 | void | 4311 | void |
4304 | choose_random_connections(struct GNUNET_TESTING_PeerGroup *pg, | 4312 | choose_random_connections(struct GNUNET_TESTING_PeerGroup *pg, |
4305 | double percentage) | 4313 | double percentage) |
4306 | { | 4314 | { |
4307 | struct RandomContext random_ctx; | 4315 | struct RandomContext random_ctx; |
4308 | uint32_t pg_iter; | 4316 | uint32_t pg_iter; |
@@ -4804,7 +4812,7 @@ perform_dfs(struct GNUNET_TESTING_PeerGroup *pg, unsigned int num) | |||
4804 | */ | 4812 | */ |
4805 | static void | 4813 | static void |
4806 | internal_topology_callback(void *cls, const struct GNUNET_PeerIdentity *peer, | 4814 | internal_topology_callback(void *cls, const struct GNUNET_PeerIdentity *peer, |
4807 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 4815 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
4808 | { | 4816 | { |
4809 | struct CoreContext *core_ctx = cls; | 4817 | struct CoreContext *core_ctx = cls; |
4810 | struct TopologyIterateContext *iter_ctx = core_ctx->iter_context; | 4818 | struct TopologyIterateContext *iter_ctx = core_ctx->iter_context; |
@@ -4881,7 +4889,7 @@ schedule_get_topology(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
4881 | */ | 4889 | */ |
4882 | void | 4890 | void |
4883 | GNUNET_TESTING_get_topology(struct GNUNET_TESTING_PeerGroup *pg, | 4891 | GNUNET_TESTING_get_topology(struct GNUNET_TESTING_PeerGroup *pg, |
4884 | GNUNET_TESTING_NotifyTopology cb, void *cls) | 4892 | GNUNET_TESTING_NotifyTopology cb, void *cls) |
4885 | { | 4893 | { |
4886 | struct TopologyIterateContext *topology_context; | 4894 | struct TopologyIterateContext *topology_context; |
4887 | struct CoreContext *core_ctx; | 4895 | struct CoreContext *core_ctx; |
@@ -4932,7 +4940,7 @@ GNUNET_TESTING_get_topology(struct GNUNET_TESTING_PeerGroup *pg, | |||
4932 | */ | 4940 | */ |
4933 | static int | 4941 | static int |
4934 | internal_stats_callback(void *cls, const char *subsystem, const char *name, | 4942 | internal_stats_callback(void *cls, const char *subsystem, const char *name, |
4935 | uint64_t value, int is_persistent) | 4943 | uint64_t value, int is_persistent) |
4936 | { | 4944 | { |
4937 | struct StatsCoreContext *core_context = cls; | 4945 | struct StatsCoreContext *core_context = cls; |
4938 | struct StatsIterateContext *stats_context = | 4946 | struct StatsIterateContext *stats_context = |
@@ -4977,7 +4985,7 @@ internal_stats_cont(void *cls, int success) | |||
4977 | */ | 4985 | */ |
4978 | static void | 4986 | static void |
4979 | schedule_get_statistics(void *cls, | 4987 | schedule_get_statistics(void *cls, |
4980 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 4988 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
4981 | { | 4989 | { |
4982 | struct StatsCoreContext *core_context = cls; | 4990 | struct StatsCoreContext *core_context = cls; |
4983 | struct StatsIterateContext *stats_context = | 4991 | struct StatsIterateContext *stats_context = |
@@ -5053,7 +5061,8 @@ struct DuplicateStats | |||
5053 | */ | 5061 | */ |
5054 | static int | 5062 | static int |
5055 | stats_check_existing(struct GNUNET_TESTING_PeerGroup *pg, | 5063 | stats_check_existing(struct GNUNET_TESTING_PeerGroup *pg, |
5056 | struct PeerData *specific_peer, struct DuplicateStats **stats_list) | 5064 | struct PeerData *specific_peer, |
5065 | struct DuplicateStats **stats_list) | ||
5057 | { | 5066 | { |
5058 | struct DuplicateStats *pos; | 5067 | struct DuplicateStats *pos; |
5059 | char *unix_domain_socket; | 5068 | char *unix_domain_socket; |
@@ -5109,8 +5118,9 @@ stats_check_existing(struct GNUNET_TESTING_PeerGroup *pg, | |||
5109 | */ | 5118 | */ |
5110 | void | 5119 | void |
5111 | GNUNET_TESTING_get_statistics(struct GNUNET_TESTING_PeerGroup *pg, | 5120 | GNUNET_TESTING_get_statistics(struct GNUNET_TESTING_PeerGroup *pg, |
5112 | GNUNET_STATISTICS_Callback cont, GNUNET_TESTING_STATISTICS_Iterator proc, | 5121 | GNUNET_STATISTICS_Callback cont, |
5113 | void *cls) | 5122 | GNUNET_TESTING_STATISTICS_Iterator proc, |
5123 | void *cls) | ||
5114 | { | 5124 | { |
5115 | struct StatsIterateContext *stats_context; | 5125 | struct StatsIterateContext *stats_context; |
5116 | struct StatsCoreContext *core_ctx; | 5126 | struct StatsCoreContext *core_ctx; |
@@ -5205,11 +5215,15 @@ GNUNET_TESTING_resume_connections(struct GNUNET_TESTING_PeerGroup *pg) | |||
5205 | * @return the number of connections that will be attempted, GNUNET_SYSERR on error | 5215 | * @return the number of connections that will be attempted, GNUNET_SYSERR on error |
5206 | */ | 5216 | */ |
5207 | int | 5217 | int |
5208 | GNUNET_TESTING_connect_topology(struct GNUNET_TESTING_PeerGroup *pg, | 5218 | GNUNET_TESTING_connect_topology( |
5209 | enum GNUNET_TESTING_Topology topology, | 5219 | struct GNUNET_TESTING_PeerGroup *pg, |
5210 | enum GNUNET_TESTING_TopologyOption options, double option_modifier, | 5220 | enum GNUNET_TESTING_Topology topology, |
5211 | struct GNUNET_TIME_Relative connect_timeout, unsigned int connect_attempts, | 5221 | enum GNUNET_TESTING_TopologyOption options, |
5212 | GNUNET_TESTING_NotifyCompletion notify_callback, void *notify_cls) | 5222 | double option_modifier, |
5223 | struct GNUNET_TIME_Relative connect_timeout, | ||
5224 | unsigned int connect_attempts, | ||
5225 | GNUNET_TESTING_NotifyCompletion notify_callback, | ||
5226 | void *notify_cls) | ||
5213 | { | 5227 | { |
5214 | switch (topology) | 5228 | switch (topology) |
5215 | { | 5229 | { |
@@ -5348,7 +5362,7 @@ GNUNET_TESTING_connect_topology(struct GNUNET_TESTING_PeerGroup *pg, | |||
5348 | */ | 5362 | */ |
5349 | static unsigned int | 5363 | static unsigned int |
5350 | count_outstanding_at_host(const char *hostname, | 5364 | count_outstanding_at_host(const char *hostname, |
5351 | struct GNUNET_TESTING_PeerGroup *pg) | 5365 | struct GNUNET_TESTING_PeerGroup *pg) |
5352 | { | 5366 | { |
5353 | struct OutstandingSSH *pos; | 5367 | struct OutstandingSSH *pos; |
5354 | pos = pg->ssh_head; | 5368 | pos = pg->ssh_head; |
@@ -5367,7 +5381,7 @@ count_outstanding_at_host(const char *hostname, | |||
5367 | */ | 5381 | */ |
5368 | static void | 5382 | static void |
5369 | increment_outstanding_at_host(const char *hostname, | 5383 | increment_outstanding_at_host(const char *hostname, |
5370 | struct GNUNET_TESTING_PeerGroup *pg) | 5384 | struct GNUNET_TESTING_PeerGroup *pg) |
5371 | { | 5385 | { |
5372 | struct OutstandingSSH *pos; | 5386 | struct OutstandingSSH *pos; |
5373 | pos = pg->ssh_head; | 5387 | pos = pg->ssh_head; |
@@ -5386,7 +5400,7 @@ increment_outstanding_at_host(const char *hostname, | |||
5386 | */ | 5400 | */ |
5387 | static void | 5401 | static void |
5388 | decrement_outstanding_at_host(const char *hostname, | 5402 | decrement_outstanding_at_host(const char *hostname, |
5389 | struct GNUNET_TESTING_PeerGroup *pg) | 5403 | struct GNUNET_TESTING_PeerGroup *pg) |
5390 | { | 5404 | { |
5391 | struct OutstandingSSH *pos; | 5405 | struct OutstandingSSH *pos; |
5392 | pos = pg->ssh_head; | 5406 | pos = pg->ssh_head; |
@@ -5408,7 +5422,7 @@ decrement_outstanding_at_host(const char *hostname, | |||
5408 | */ | 5422 | */ |
5409 | static void | 5423 | static void |
5410 | internal_hostkey_callback(void *cls, const struct GNUNET_PeerIdentity *id, | 5424 | internal_hostkey_callback(void *cls, const struct GNUNET_PeerIdentity *id, |
5411 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 5425 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
5412 | { | 5426 | { |
5413 | struct InternalStartContext *internal_context = cls; | 5427 | struct InternalStartContext *internal_context = cls; |
5414 | internal_context->peer->pg->starting--; | 5428 | internal_context->peer->pg->starting--; |
@@ -5440,8 +5454,8 @@ internal_hostkey_callback(void *cls, const struct GNUNET_PeerIdentity *id, | |||
5440 | */ | 5454 | */ |
5441 | static void | 5455 | static void |
5442 | internal_startup_callback(void *cls, const struct GNUNET_PeerIdentity *id, | 5456 | internal_startup_callback(void *cls, const struct GNUNET_PeerIdentity *id, |
5443 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 5457 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
5444 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 5458 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
5445 | { | 5459 | { |
5446 | struct InternalStartContext *internal_context = cls; | 5460 | struct InternalStartContext *internal_context = cls; |
5447 | internal_context->peer->pg->starting--; | 5461 | internal_context->peer->pg->starting--; |
@@ -5455,7 +5469,7 @@ internal_startup_callback(void *cls, const struct GNUNET_PeerIdentity *id, | |||
5455 | 5469 | ||
5456 | static void | 5470 | static void |
5457 | internal_continue_startup(void *cls, | 5471 | internal_continue_startup(void *cls, |
5458 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 5472 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
5459 | { | 5473 | { |
5460 | struct InternalStartContext *internal_context = cls; | 5474 | struct InternalStartContext *internal_context = cls; |
5461 | 5475 | ||
@@ -5501,8 +5515,8 @@ internal_continue_startup(void *cls, | |||
5501 | */ | 5515 | */ |
5502 | void | 5516 | void |
5503 | churn_start_callback(void *cls, const struct GNUNET_PeerIdentity *id, | 5517 | churn_start_callback(void *cls, const struct GNUNET_PeerIdentity *id, |
5504 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 5518 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
5505 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 5519 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
5506 | { | 5520 | { |
5507 | struct ChurnRestartContext *startup_ctx = cls; | 5521 | struct ChurnRestartContext *startup_ctx = cls; |
5508 | struct ChurnContext *churn_ctx = startup_ctx->churn_ctx; | 5522 | struct ChurnContext *churn_ctx = startup_ctx->churn_ctx; |
@@ -5658,13 +5672,19 @@ GNUNET_TESTING_daemons_continue_startup(struct GNUNET_TESTING_PeerGroup *pg) | |||
5658 | * @return NULL on error, otherwise handle to control peer group | 5672 | * @return NULL on error, otherwise handle to control peer group |
5659 | */ | 5673 | */ |
5660 | struct GNUNET_TESTING_PeerGroup * | 5674 | struct GNUNET_TESTING_PeerGroup * |
5661 | GNUNET_TESTING_daemons_start(const struct GNUNET_CONFIGURATION_Handle *cfg, | 5675 | GNUNET_TESTING_daemons_start( |
5662 | unsigned int total, unsigned int max_concurrent_connections, | 5676 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
5663 | unsigned int max_concurrent_ssh, struct GNUNET_TIME_Relative timeout, | 5677 | unsigned int total, |
5664 | GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback, void *hostkey_cls, | 5678 | unsigned int max_concurrent_connections, |
5665 | GNUNET_TESTING_NotifyDaemonRunning cb, void *cb_cls, | 5679 | unsigned int max_concurrent_ssh, |
5666 | GNUNET_TESTING_NotifyConnection connect_callback, | 5680 | struct GNUNET_TIME_Relative timeout, |
5667 | void *connect_callback_cls, const struct GNUNET_TESTING_Host *hostnames) | 5681 | GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback, |
5682 | void *hostkey_cls, | ||
5683 | GNUNET_TESTING_NotifyDaemonRunning cb, | ||
5684 | void *cb_cls, | ||
5685 | GNUNET_TESTING_NotifyConnection connect_callback, | ||
5686 | void *connect_callback_cls, | ||
5687 | const struct GNUNET_TESTING_Host *hostnames) | ||
5668 | { | 5688 | { |
5669 | struct GNUNET_TESTING_PeerGroup *pg; | 5689 | struct GNUNET_TESTING_PeerGroup *pg; |
5670 | const struct GNUNET_TESTING_Host *hostpos; | 5690 | const struct GNUNET_TESTING_Host *hostpos; |
@@ -5956,7 +5976,7 @@ GNUNET_TESTING_daemons_start(const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
5956 | */ | 5976 | */ |
5957 | struct GNUNET_TESTING_Daemon * | 5977 | struct GNUNET_TESTING_Daemon * |
5958 | GNUNET_TESTING_daemon_get(struct GNUNET_TESTING_PeerGroup *pg, | 5978 | GNUNET_TESTING_daemon_get(struct GNUNET_TESTING_PeerGroup *pg, |
5959 | unsigned int position) | 5979 | unsigned int position) |
5960 | { | 5980 | { |
5961 | if (position < pg->total) | 5981 | if (position < pg->total) |
5962 | return pg->peers[position].daemon; | 5982 | return pg->peers[position].daemon; |
@@ -5975,7 +5995,7 @@ GNUNET_TESTING_daemon_get(struct GNUNET_TESTING_PeerGroup *pg, | |||
5975 | */ | 5995 | */ |
5976 | struct GNUNET_TESTING_Daemon * | 5996 | struct GNUNET_TESTING_Daemon * |
5977 | GNUNET_TESTING_daemon_get_by_id(struct GNUNET_TESTING_PeerGroup *pg, | 5997 | GNUNET_TESTING_daemon_get_by_id(struct GNUNET_TESTING_PeerGroup *pg, |
5978 | struct GNUNET_PeerIdentity *peer_id) | 5998 | struct GNUNET_PeerIdentity *peer_id) |
5979 | { | 5999 | { |
5980 | unsigned int i; | 6000 | unsigned int i; |
5981 | 6001 | ||
@@ -6001,8 +6021,8 @@ GNUNET_TESTING_daemon_get_by_id(struct GNUNET_TESTING_PeerGroup *pg, | |||
6001 | */ | 6021 | */ |
6002 | void | 6022 | void |
6003 | restart_callback(void *cls, const struct GNUNET_PeerIdentity *id, | 6023 | restart_callback(void *cls, const struct GNUNET_PeerIdentity *id, |
6004 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 6024 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
6005 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 6025 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
6006 | { | 6026 | { |
6007 | struct RestartContext *restart_context = cls; | 6027 | struct RestartContext *restart_context = cls; |
6008 | 6028 | ||
@@ -6116,7 +6136,7 @@ GNUNET_TESTING_daemons_running(struct GNUNET_TESTING_PeerGroup *pg) | |||
6116 | */ | 6136 | */ |
6117 | static void | 6137 | static void |
6118 | schedule_churn_shutdown_task(void *cls, | 6138 | schedule_churn_shutdown_task(void *cls, |
6119 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 6139 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
6120 | { | 6140 | { |
6121 | struct PeerShutdownContext *peer_shutdown_ctx = cls; | 6141 | struct PeerShutdownContext *peer_shutdown_ctx = cls; |
6122 | struct ShutdownContext *shutdown_ctx; | 6142 | struct ShutdownContext *shutdown_ctx; |
@@ -6164,8 +6184,9 @@ schedule_churn_shutdown_task(void *cls, | |||
6164 | */ | 6184 | */ |
6165 | void | 6185 | void |
6166 | GNUNET_TESTING_daemons_churn(struct GNUNET_TESTING_PeerGroup *pg, | 6186 | GNUNET_TESTING_daemons_churn(struct GNUNET_TESTING_PeerGroup *pg, |
6167 | unsigned int voff, unsigned int von, struct GNUNET_TIME_Relative timeout, | 6187 | unsigned int voff, unsigned int von, |
6168 | GNUNET_TESTING_NotifyCompletion cb, void *cb_cls) | 6188 | struct GNUNET_TIME_Relative timeout, |
6189 | GNUNET_TESTING_NotifyCompletion cb, void *cb_cls) | ||
6169 | { | 6190 | { |
6170 | struct ChurnContext *churn_ctx; | 6191 | struct ChurnContext *churn_ctx; |
6171 | struct ShutdownContext *shutdown_ctx; | 6192 | struct ShutdownContext *shutdown_ctx; |
@@ -6340,7 +6361,8 @@ GNUNET_TESTING_daemons_churn(struct GNUNET_TESTING_PeerGroup *pg, | |||
6340 | */ | 6361 | */ |
6341 | void | 6362 | void |
6342 | GNUNET_TESTING_daemons_restart(struct GNUNET_TESTING_PeerGroup *pg, | 6363 | GNUNET_TESTING_daemons_restart(struct GNUNET_TESTING_PeerGroup *pg, |
6343 | GNUNET_TESTING_NotifyCompletion callback, void *callback_cls) | 6364 | GNUNET_TESTING_NotifyCompletion callback, |
6365 | void *callback_cls) | ||
6344 | { | 6366 | { |
6345 | struct RestartContext *restart_context; | 6367 | struct RestartContext *restart_context; |
6346 | unsigned int off; | 6368 | unsigned int off; |
@@ -6373,9 +6395,9 @@ GNUNET_TESTING_daemons_restart(struct GNUNET_TESTING_PeerGroup *pg, | |||
6373 | */ | 6395 | */ |
6374 | void | 6396 | void |
6375 | GNUNET_TESTING_daemons_vary(struct GNUNET_TESTING_PeerGroup *pg, | 6397 | GNUNET_TESTING_daemons_vary(struct GNUNET_TESTING_PeerGroup *pg, |
6376 | unsigned int offset, int desired_status, | 6398 | unsigned int offset, int desired_status, |
6377 | struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_NotifyCompletion cb, | 6399 | struct GNUNET_TIME_Relative timeout, |
6378 | void *cb_cls) | 6400 | GNUNET_TESTING_NotifyCompletion cb, void *cb_cls) |
6379 | { | 6401 | { |
6380 | struct ShutdownContext *shutdown_ctx; | 6402 | struct ShutdownContext *shutdown_ctx; |
6381 | struct ChurnRestartContext *startup_ctx; | 6403 | struct ChurnRestartContext *startup_ctx; |
@@ -6426,10 +6448,15 @@ GNUNET_TESTING_daemons_vary(struct GNUNET_TESTING_PeerGroup *pg, | |||
6426 | void | 6448 | void |
6427 | internal_shutdown_callback(void *cls, const char *emsg) | 6449 | internal_shutdown_callback(void *cls, const char *emsg) |
6428 | { | 6450 | { |
6451 | struct PeerShutdownContext *peer_shutdown_ctx = cls; | ||
6429 | struct ShutdownContext *shutdown_ctx = cls; | 6452 | struct ShutdownContext *shutdown_ctx = cls; |
6430 | unsigned int off; | 6453 | unsigned int off; |
6431 | 6454 | ||
6432 | shutdown_ctx->outstanding--; | 6455 | shutdown_ctx->outstanding--; |
6456 | if (peer_shutdown_ctx->daemon->hostname != NULL) | ||
6457 | decrement_outstanding_at_host (peer_shutdown_ctx->daemon->hostname, | ||
6458 | shutdown_ctx->pg); | ||
6459 | |||
6433 | if (emsg == NULL) | 6460 | if (emsg == NULL) |
6434 | { | 6461 | { |
6435 | shutdown_ctx->peers_down++; | 6462 | shutdown_ctx->peers_down++; |
@@ -6460,6 +6487,7 @@ internal_shutdown_callback(void *cls, const char *emsg) | |||
6460 | 6487 | ||
6461 | GNUNET_free (shutdown_ctx); | 6488 | GNUNET_free (shutdown_ctx); |
6462 | } | 6489 | } |
6490 | GNUNET_free(peer_shutdown_ctx); | ||
6463 | } | 6491 | } |
6464 | 6492 | ||
6465 | /** | 6493 | /** |
@@ -6479,21 +6507,26 @@ schedule_shutdown_task(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
6479 | shutdown_ctx = peer_shutdown_ctx->shutdown_ctx; | 6507 | shutdown_ctx = peer_shutdown_ctx->shutdown_ctx; |
6480 | GNUNET_assert (shutdown_ctx != NULL); | 6508 | GNUNET_assert (shutdown_ctx != NULL); |
6481 | 6509 | ||
6482 | if (shutdown_ctx->outstanding > shutdown_ctx->pg->max_concurrent_ssh) | 6510 | if ((shutdown_ctx->outstanding < shutdown_ctx->pg->max_concurrent_ssh) |
6483 | GNUNET_SCHEDULER_add_delayed ( | 6511 | || ((peer_shutdown_ctx->daemon->hostname != NULL) |
6484 | GNUNET_TIME_relative_multiply ( | 6512 | && (count_outstanding_at_host (peer_shutdown_ctx->daemon->hostname, |
6485 | GNUNET_TIME_UNIT_MILLISECONDS, | 6513 | shutdown_ctx->pg) |
6486 | 100), | 6514 | < shutdown_ctx->pg->max_concurrent_ssh))) |
6487 | &schedule_shutdown_task, peer_shutdown_ctx); | ||
6488 | else | ||
6489 | { | 6515 | { |
6516 | if (peer_shutdown_ctx->daemon->hostname != NULL) | ||
6517 | increment_outstanding_at_host (peer_shutdown_ctx->daemon->hostname, | ||
6518 | shutdown_ctx->pg); | ||
6490 | shutdown_ctx->outstanding++; | 6519 | shutdown_ctx->outstanding++; |
6491 | GNUNET_TESTING_daemon_stop (peer_shutdown_ctx->daemon, | 6520 | GNUNET_TESTING_daemon_stop (peer_shutdown_ctx->daemon, |
6492 | shutdown_ctx->timeout, | 6521 | shutdown_ctx->timeout, |
6493 | &internal_shutdown_callback, shutdown_ctx, | 6522 | &internal_shutdown_callback, peer_shutdown_ctx, |
6494 | GNUNET_YES, GNUNET_NO); | 6523 | GNUNET_YES, GNUNET_NO); |
6495 | GNUNET_free (peer_shutdown_ctx); | ||
6496 | } | 6524 | } |
6525 | else | ||
6526 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | ||
6527 | 100), | ||
6528 | &schedule_shutdown_task, peer_shutdown_ctx); | ||
6529 | |||
6497 | } | 6530 | } |
6498 | 6531 | ||
6499 | /** | 6532 | /** |
@@ -6506,8 +6539,8 @@ schedule_shutdown_task(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
6506 | */ | 6539 | */ |
6507 | void | 6540 | void |
6508 | GNUNET_TESTING_daemons_stop(struct GNUNET_TESTING_PeerGroup *pg, | 6541 | GNUNET_TESTING_daemons_stop(struct GNUNET_TESTING_PeerGroup *pg, |
6509 | struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_NotifyCompletion cb, | 6542 | struct GNUNET_TIME_Relative timeout, |
6510 | void *cb_cls) | 6543 | GNUNET_TESTING_NotifyCompletion cb, void *cb_cls) |
6511 | { | 6544 | { |
6512 | unsigned int off; | 6545 | unsigned int off; |
6513 | struct ShutdownContext *shutdown_ctx; | 6546 | struct ShutdownContext *shutdown_ctx; |
@@ -6579,7 +6612,6 @@ GNUNET_TESTING_daemons_stop(struct GNUNET_TESTING_PeerGroup *pg, | |||
6579 | peers[off].blacklisted_peers); | 6612 | peers[off].blacklisted_peers); |
6580 | #endif | 6613 | #endif |
6581 | } | 6614 | } |
6582 | |||
6583 | } | 6615 | } |
6584 | 6616 | ||
6585 | /* end of testing_group.c */ | 6617 | /* end of testing_group.c */ |