aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2011-02-17 13:29:47 +0000
committerNathan S. Evans <evans@in.tum.de>2011-02-17 13:29:47 +0000
commit0d95267569574f8381791e913e0ac6abf6d1e38b (patch)
treeae5ef862764bcb1a8dafb49fb927d42bd98323bf /src/testing
parentfe87e6648752f01771f571ef6dc7cae7de4ae66e (diff)
downloadgnunet-0d95267569574f8381791e913e0ac6abf6d1e38b.tar.gz
gnunet-0d95267569574f8381791e913e0ac6abf6d1e38b.zip
Allow testing connection process to be stopped when asked.
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/testing_group.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index f9b3cc3fc..fc527efe3 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -702,6 +702,11 @@ struct GNUNET_TESTING_PeerGroup
702 * ssh connections per peer. 702 * ssh connections per peer.
703 */ 703 */
704 struct OutstandingSSH *ssh_tail; 704 struct OutstandingSSH *ssh_tail;
705
706 /**
707 * Stop scheduling peers connecting.
708 */
709 unsigned int stop_connects;
705}; 710};
706 711
707struct UpdateContext 712struct UpdateContext
@@ -2904,8 +2909,9 @@ static void preschedule_connect(struct ConnectTopologyContext *ct_ctx)
2904 random_peer = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, pg->total); 2909 random_peer = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, pg->total);
2905 2910
2906 connection_iter = pg->peers[random_peer].connect_peers_head; 2911 connection_iter = pg->peers[random_peer].connect_peers_head;
2912#if DEBUG_TESTING
2907 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Scheduling connection between %d and %d\n", random_peer, connection_iter->index); 2913 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Scheduling connection between %d and %d\n", random_peer, connection_iter->index);
2908 2914#endif
2909 connect_context = GNUNET_malloc (sizeof (struct ConnectContext)); 2915 connect_context = GNUNET_malloc (sizeof (struct ConnectContext));
2910 connect_context->first = pg->peers[random_peer].daemon; 2916 connect_context->first = pg->peers[random_peer].daemon;
2911 connect_context->second = pg->peers[connection_iter->index].daemon; 2917 connect_context->second = pg->peers[connection_iter->index].daemon;
@@ -2967,7 +2973,7 @@ schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2967 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) 2973 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
2968 return; 2974 return;
2969 2975
2970 if (pg->outstanding_connects > pg->max_outstanding_connections) 2976 if ((pg->outstanding_connects > pg->max_outstanding_connections) || (pg->stop_connects == GNUNET_YES))
2971 { 2977 {
2972#if VERBOSE_TESTING > 2 2978#if VERBOSE_TESTING > 2
2973 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2979 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -4443,6 +4449,26 @@ GNUNET_TESTING_get_statistics (struct GNUNET_TESTING_PeerGroup *pg,
4443} 4449}
4444 4450
4445/** 4451/**
4452 * Stop the connection process temporarily.
4453 *
4454 * @param pg the peer group to stop connecting
4455 */
4456void GNUNET_TESTING_stop_connections(struct GNUNET_TESTING_PeerGroup *pg)
4457{
4458 pg->stop_connects = GNUNET_YES;
4459}
4460
4461/**
4462 * Resume the connection process temporarily.
4463 *
4464 * @param pg the peer group to resume connecting
4465 */
4466void GNUNET_TESTING_resume_connections(struct GNUNET_TESTING_PeerGroup *pg)
4467{
4468 pg->stop_connects = GNUNET_NO;
4469}
4470
4471/**
4446 * There are many ways to connect peers that are supported by this function. 4472 * There are many ways to connect peers that are supported by this function.
4447 * To connect peers in the same topology that was created via the 4473 * To connect peers in the same topology that was created via the
4448 * GNUNET_TESTING_create_topology, the topology variable must be set to 4474 * GNUNET_TESTING_create_topology, the topology variable must be set to