aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2011-02-28 11:06:03 +0000
committerNathan S. Evans <evans@in.tum.de>2011-02-28 11:06:03 +0000
commit6b5bb22d6a3c40fd15aa4f87b1e520c0723065ff (patch)
tree2df170b3ba6fdcd3d333ec3f6ba1015dad67a734 /src/testing
parent9982ecf65db1f4c20e50dabfe355188455b7d8dc (diff)
downloadgnunet-6b5bb22d6a3c40fd15aa4f87b1e520c0723065ff.tar.gz
gnunet-6b5bb22d6a3c40fd15aa4f87b1e520c0723065ff.zip
code format, fix shutdown bottleneck
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/testing_group.c202
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 */
85typedef unsigned int 85typedef 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 */
1106int 1106int
1107GNUNET_TESTING_topology_get(enum GNUNET_TESTING_Topology *topology, 1107GNUNET_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 */
1198int 1198int
1199GNUNET_TESTING_topology_option_get( 1199GNUNET_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 */
1271static void 1271static void
1272update_config(void *cls, const char *section, const char *option, 1272update_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 */
1357static struct GNUNET_CONFIGURATION_Handle * 1357static struct GNUNET_CONFIGURATION_Handle *
1358make_config(const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off, 1358make_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 */
1451static unsigned int 1452static unsigned int
1452remove_connections(struct GNUNET_TESTING_PeerGroup *pg, unsigned int first, 1453remove_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 */
1564static unsigned int 1565static unsigned int
1565add_connections(struct GNUNET_TESTING_PeerGroup *pg, unsigned int first, 1566add_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 */
1723static unsigned int 1724static unsigned int
1724create_scale_free(struct GNUNET_TESTING_PeerGroup *pg, 1725create_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 */
1797static unsigned int 1798static unsigned int
1798create_small_world_ring(struct GNUNET_TESTING_PeerGroup *pg, 1799create_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 */
1922static unsigned int 1924static unsigned int
1923create_nated_internet(struct GNUNET_TESTING_PeerGroup *pg, 1925create_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 */
1980static unsigned int 1983static unsigned int
1981create_nated_internet_copy(struct GNUNET_TESTING_PeerGroup *pg, 1984create_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 */
2056static unsigned int 2060static unsigned int
2057create_small_world(struct GNUNET_TESTING_PeerGroup *pg, 2061create_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 */
2231static unsigned int 2235static unsigned int
2232create_erdos_renyi(struct GNUNET_TESTING_PeerGroup *pg, 2236create_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 */
2294static unsigned int 2298static unsigned int
2295create_2d_torus(struct GNUNET_TESTING_PeerGroup *pg, 2299create_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 */
2388static unsigned int 2392static unsigned int
2389create_clique(struct GNUNET_TESTING_PeerGroup *pg, 2393create_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 */
2461static unsigned int 2465static unsigned int
2462copy_allowed(struct GNUNET_TESTING_PeerGroup *pg, 2466copy_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 */
2503static unsigned int 2507static unsigned int
2504create_line(struct GNUNET_TESTING_PeerGroup *pg, 2508create_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 */
2538static unsigned int 2542static unsigned int
2539create_from_file(struct GNUNET_TESTING_PeerGroup *pg, char *filename, 2543create_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 */
2684static unsigned int 2688static unsigned int
2685create_ring(struct GNUNET_TESTING_PeerGroup *pg, 2689create_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 */
2956static int 2960static int
2957create_and_copy_blacklist_files(struct GNUNET_TESTING_PeerGroup *pg, 2961create_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 */
3547static void 3551static void
3548internal_connect_notify(void *cls, const struct GNUNET_PeerIdentity *first, 3552internal_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 */
3772static int 3778static int
3773connect_topology(struct GNUNET_TESTING_PeerGroup *pg, 3779connect_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 */
3856unsigned int 3864unsigned int
3857GNUNET_TESTING_create_topology(struct GNUNET_TESTING_PeerGroup *pg, 3865GNUNET_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 */
4303void 4311void
4304choose_random_connections(struct GNUNET_TESTING_PeerGroup *pg, 4312choose_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 */
4805static void 4813static void
4806internal_topology_callback(void *cls, const struct GNUNET_PeerIdentity *peer, 4814internal_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 */
4882void 4890void
4883GNUNET_TESTING_get_topology(struct GNUNET_TESTING_PeerGroup *pg, 4891GNUNET_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 */
4933static int 4941static int
4934internal_stats_callback(void *cls, const char *subsystem, const char *name, 4942internal_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 */
4978static void 4986static void
4979schedule_get_statistics(void *cls, 4987schedule_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 */
5054static int 5062static int
5055stats_check_existing(struct GNUNET_TESTING_PeerGroup *pg, 5063stats_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 */
5110void 5119void
5111GNUNET_TESTING_get_statistics(struct GNUNET_TESTING_PeerGroup *pg, 5120GNUNET_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 */
5207int 5217int
5208GNUNET_TESTING_connect_topology(struct GNUNET_TESTING_PeerGroup *pg, 5218GNUNET_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 */
5349static unsigned int 5363static unsigned int
5350count_outstanding_at_host(const char *hostname, 5364count_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 */
5368static void 5382static void
5369increment_outstanding_at_host(const char *hostname, 5383increment_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 */
5387static void 5401static void
5388decrement_outstanding_at_host(const char *hostname, 5402decrement_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 */
5409static void 5423static void
5410internal_hostkey_callback(void *cls, const struct GNUNET_PeerIdentity *id, 5424internal_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 */
5441static void 5455static void
5442internal_startup_callback(void *cls, const struct GNUNET_PeerIdentity *id, 5456internal_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
5456static void 5470static void
5457internal_continue_startup(void *cls, 5471internal_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 */
5502void 5516void
5503churn_start_callback(void *cls, const struct GNUNET_PeerIdentity *id, 5517churn_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 */
5660struct GNUNET_TESTING_PeerGroup * 5674struct GNUNET_TESTING_PeerGroup *
5661GNUNET_TESTING_daemons_start(const struct GNUNET_CONFIGURATION_Handle *cfg, 5675GNUNET_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 */
5957struct GNUNET_TESTING_Daemon * 5977struct GNUNET_TESTING_Daemon *
5958GNUNET_TESTING_daemon_get(struct GNUNET_TESTING_PeerGroup *pg, 5978GNUNET_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 */
5976struct GNUNET_TESTING_Daemon * 5996struct GNUNET_TESTING_Daemon *
5977GNUNET_TESTING_daemon_get_by_id(struct GNUNET_TESTING_PeerGroup *pg, 5997GNUNET_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 */
6002void 6022void
6003restart_callback(void *cls, const struct GNUNET_PeerIdentity *id, 6023restart_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 */
6117static void 6137static void
6118schedule_churn_shutdown_task(void *cls, 6138schedule_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 */
6165void 6185void
6166GNUNET_TESTING_daemons_churn(struct GNUNET_TESTING_PeerGroup *pg, 6186GNUNET_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 */
6341void 6362void
6342GNUNET_TESTING_daemons_restart(struct GNUNET_TESTING_PeerGroup *pg, 6363GNUNET_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 */
6374void 6396void
6375GNUNET_TESTING_daemons_vary(struct GNUNET_TESTING_PeerGroup *pg, 6397GNUNET_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,
6426void 6448void
6427internal_shutdown_callback(void *cls, const char *emsg) 6449internal_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 */
6507void 6540void
6508GNUNET_TESTING_daemons_stop(struct GNUNET_TESTING_PeerGroup *pg, 6541GNUNET_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 */