aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_group.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2011-02-15 11:56:03 +0000
committerNathan S. Evans <evans@in.tum.de>2011-02-15 11:56:03 +0000
commit66dd280cc10564606ebba1eb17b9e4c171ca83fb (patch)
treedda7b21bcbec9cbc9bb4c3b81103ee305ea4c938 /src/testing/testing_group.c
parent72aa3a0c2a970ae8303ea4b29bef76371b59f6be (diff)
downloadgnunet-66dd280cc10564606ebba1eb17b9e4c171ca83fb.tar.gz
gnunet-66dd280cc10564606ebba1eb17b9e4c171ca83fb.zip
change to allow number of outstanding ssh connections to be set separately
Diffstat (limited to 'src/testing/testing_group.c')
-rw-r--r--src/testing/testing_group.c54
1 files changed, 36 insertions, 18 deletions
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index a35a63a75..b4420115d 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -56,8 +56,6 @@
56/* Maximum time to delay connect attempt */ 56/* Maximum time to delay connect attempt */
57#define MAX_CONNECT_DELAY 300 57#define MAX_CONNECT_DELAY 300
58 58
59#define MAX_CONCURRENT_HOSTKEYS 500
60
61/** 59/**
62 * Which list of peers do we need to modify? 60 * Which list of peers do we need to modify?
63 */ 61 */
@@ -656,6 +654,11 @@ struct GNUNET_TESTING_PeerGroup
656 unsigned int max_outstanding_connections; 654 unsigned int max_outstanding_connections;
657 655
658 /** 656 /**
657 * Number of ssh connections to peers (max).
658 */
659 unsigned int max_concurrent_ssh;
660
661 /**
659 * Number of connects we are waiting on, allows us to rate limit 662 * Number of connects we are waiting on, allows us to rate limit
660 * connect attempts. 663 * connect attempts.
661 */ 664 */
@@ -1125,6 +1128,7 @@ update_config (void *cls,
1125 * out of "*port" numbers, return NULL. 1128 * out of "*port" numbers, return NULL.
1126 * 1129 *
1127 * @param cfg template configuration 1130 * @param cfg template configuration
1131 * @param off the current peer offset
1128 * @param port port numbers to use, update to reflect 1132 * @param port port numbers to use, update to reflect
1129 * port numbers that were used 1133 * port numbers that were used
1130 * @param upnum number to make unix domain socket names unique 1134 * @param upnum number to make unix domain socket names unique
@@ -1136,6 +1140,7 @@ update_config (void *cls,
1136 */ 1140 */
1137static struct GNUNET_CONFIGURATION_Handle * 1141static struct GNUNET_CONFIGURATION_Handle *
1138make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, 1142make_config (const struct GNUNET_CONFIGURATION_Handle *cfg,
1143 uint32_t off,
1139 uint16_t * port, 1144 uint16_t * port,
1140 uint32_t * upnum, const char *hostname, uint32_t * fdnum) 1145 uint32_t * upnum, const char *hostname, uint32_t * fdnum)
1141{ 1146{
@@ -1143,6 +1148,7 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg,
1143 uint16_t orig; 1148 uint16_t orig;
1144 char *control_host; 1149 char *control_host;
1145 char *allowed_hosts; 1150 char *allowed_hosts;
1151 unsigned long long temp_port;
1146 1152
1147 orig = *port; 1153 orig = *port;
1148 uc.nport = *port; 1154 uc.nport = *port;
@@ -1171,20 +1177,28 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg,
1171 1177
1172 GNUNET_CONFIGURATION_set_value_string (uc.ret, "core", "ACCEPT_FROM", 1178 GNUNET_CONFIGURATION_set_value_string (uc.ret, "core", "ACCEPT_FROM",
1173 allowed_hosts); 1179 allowed_hosts);
1174 GNUNET_CONFIGURATION_set_value_string (uc.ret, "core", "UNIXPATH",
1175 "");
1176 GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", 1180 GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport",
1177 "ACCEPT_FROM", allowed_hosts); 1181 "ACCEPT_FROM", allowed_hosts);
1178 GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "UNIXPATH",
1179 "");
1180 GNUNET_CONFIGURATION_set_value_string (uc.ret, "dht", "ACCEPT_FROM", 1182 GNUNET_CONFIGURATION_set_value_string (uc.ret, "dht", "ACCEPT_FROM",
1181 allowed_hosts); 1183 allowed_hosts);
1182 GNUNET_CONFIGURATION_set_value_string (uc.ret, "dht", "UNIXPATH",
1183 "");
1184 GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", 1184 GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics",
1185 "ACCEPT_FROM", allowed_hosts); 1185 "ACCEPT_FROM", allowed_hosts);
1186 GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", "UNIXPATH", 1186
1187 ""); 1187 GNUNET_CONFIGURATION_set_value_string (uc.ret, "core", "UNIXPATH", "");
1188 GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "UNIXPATH", "");
1189 GNUNET_CONFIGURATION_set_value_string (uc.ret, "dht", "UNIXPATH", "");
1190 GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", "UNIXPATH", "");
1191
1192
1193 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(uc.orig, "statistics", "port", &temp_port) &&
1194 (temp_port != 0) &&
1195 (GNUNET_YES !=
1196 GNUNET_CONFIGURATION_get_value_yesno (uc.orig, "testing",
1197 "single_statistics_per_host")))
1198 {
1199 GNUNET_CONFIGURATION_set_value_number (uc.ret, "statistics", "port", temp_port + off);
1200 }
1201
1188 GNUNET_free_non_null (control_host); 1202 GNUNET_free_non_null (control_host);
1189 GNUNET_free (allowed_hosts); 1203 GNUNET_free (allowed_hosts);
1190 } 1204 }
@@ -4614,7 +4628,7 @@ internal_continue_startup (void *cls,
4614 return; 4628 return;
4615 } 4629 }
4616 4630
4617 if (internal_context->peer->pg->starting < internal_context->peer->pg->max_outstanding_connections) 4631 if (internal_context->peer->pg->starting < internal_context->peer->pg->max_concurrent_ssh)
4618 { 4632 {
4619 internal_context->peer->pg->starting++; 4633 internal_context->peer->pg->starting++;
4620 GNUNET_TESTING_daemon_continue_startup (internal_context->peer->daemon); 4634 GNUNET_TESTING_daemon_continue_startup (internal_context->peer->daemon);
@@ -4697,7 +4711,7 @@ schedule_churn_restart (void *cls,
4697 struct ChurnRestartContext *startup_ctx = 4711 struct ChurnRestartContext *startup_ctx =
4698 peer_restart_ctx->churn_restart_ctx; 4712 peer_restart_ctx->churn_restart_ctx;
4699 4713
4700 if (startup_ctx->outstanding > startup_ctx->pg->max_outstanding_connections) 4714 if (startup_ctx->outstanding > startup_ctx->pg->max_concurrent_ssh)
4701 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 4715 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
4702 (GNUNET_TIME_UNIT_MILLISECONDS, 100), 4716 (GNUNET_TIME_UNIT_MILLISECONDS, 100),
4703 &schedule_churn_restart, peer_restart_ctx); 4717 &schedule_churn_restart, peer_restart_ctx);
@@ -4721,7 +4735,7 @@ internal_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
4721 return; 4735 return;
4722 } 4736 }
4723 4737
4724 if (internal_context->peer->pg->starting < MAX_CONCURRENT_HOSTKEYS) 4738 if (internal_context->peer->pg->starting < internal_context->peer->pg->max_concurrent_ssh)
4725 { 4739 {
4726 internal_context->peer->pg->starting++; 4740 internal_context->peer->pg->starting++;
4727 internal_context->peer->daemon = 4741 internal_context->peer->daemon =
@@ -4774,7 +4788,9 @@ GNUNET_TESTING_daemons_continue_startup (struct GNUNET_TESTING_PeerGroup *pg)
4774 * @param cfg configuration template to use 4788 * @param cfg configuration template to use
4775 * @param total number of daemons to start 4789 * @param total number of daemons to start
4776 * @param max_concurrent_connections for testing, how many peers can 4790 * @param max_concurrent_connections for testing, how many peers can
4777 * we connect to simultaneously 4791* we connect to simultaneously
4792 * @param max_concurrent_ssh when starting with ssh, how many ssh
4793 * connections will we allow at once (based on remote hosts allowed!)
4778 * @param timeout total time allowed for peers to start 4794 * @param timeout total time allowed for peers to start
4779 * @param hostkey_callback function to call on each peers hostkey generation 4795 * @param hostkey_callback function to call on each peers hostkey generation
4780 * if NULL, peers will be started by this call, if non-null, 4796 * if NULL, peers will be started by this call, if non-null,
@@ -4794,6 +4810,7 @@ struct GNUNET_TESTING_PeerGroup *
4794GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, 4810GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
4795 unsigned int total, 4811 unsigned int total,
4796 unsigned int max_concurrent_connections, 4812 unsigned int max_concurrent_connections,
4813 unsigned int max_concurrent_ssh,
4797 struct GNUNET_TIME_Relative timeout, 4814 struct GNUNET_TIME_Relative timeout,
4798 GNUNET_TESTING_NotifyHostkeyCreated 4815 GNUNET_TESTING_NotifyHostkeyCreated
4799 hostkey_callback, void *hostkey_cls, 4816 hostkey_callback, void *hostkey_cls,
@@ -4847,6 +4864,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
4847 pg->max_timeout = GNUNET_TIME_relative_to_absolute (timeout); 4864 pg->max_timeout = GNUNET_TIME_relative_to_absolute (timeout);
4848 pg->peers = GNUNET_malloc (total * sizeof (struct PeerData)); 4865 pg->peers = GNUNET_malloc (total * sizeof (struct PeerData));
4849 pg->max_outstanding_connections = max_concurrent_connections; 4866 pg->max_outstanding_connections = max_concurrent_connections;
4867 pg->max_concurrent_ssh = max_concurrent_ssh;
4850 if (NULL != hostnames) 4868 if (NULL != hostnames)
4851 { 4869 {
4852 off = 0; 4870 off = 0;
@@ -4935,7 +4953,6 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
4935 &baseservicehome)); 4953 &baseservicehome));
4936 for (i = 0; i < pg->num_hosts; i++) 4954 for (i = 0; i < pg->num_hosts; i++)
4937 { 4955 {
4938
4939 if (NULL != pg->hosts[i].username) 4956 if (NULL != pg->hosts[i].username)
4940 GNUNET_asprintf (&arg, "%s@%s", pg->hosts[i].username, pg->hosts[i].hostname); 4957 GNUNET_asprintf (&arg, "%s@%s", pg->hosts[i].username, pg->hosts[i].hostname);
4941 else 4958 else
@@ -5003,6 +5020,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
5003 username = pg->hosts[off % hostcnt].username; 5020 username = pg->hosts[off % hostcnt].username;
5004 sshport = pg->hosts[off % hostcnt].sshport; 5021 sshport = pg->hosts[off % hostcnt].sshport;
5005 pcfg = make_config (cfg, 5022 pcfg = make_config (cfg,
5023 off,
5006 &pg->hosts[off % hostcnt].minport, 5024 &pg->hosts[off % hostcnt].minport,
5007 &upnum, hostname, &fdnum); 5025 &upnum, hostname, &fdnum);
5008 } 5026 }
@@ -5011,7 +5029,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
5011 hostname = NULL; 5029 hostname = NULL;
5012 username = NULL; 5030 username = NULL;
5013 sshport = 0; 5031 sshport = 0;
5014 pcfg = make_config (cfg, &minport, &upnum, hostname, &fdnum); 5032 pcfg = make_config (cfg, off, &minport, &upnum, hostname, &fdnum);
5015 } 5033 }
5016 5034
5017 if (NULL == pcfg) 5035 if (NULL == pcfg)
@@ -5252,7 +5270,7 @@ schedule_churn_shutdown_task (void *cls,
5252 shutdown_ctx = peer_shutdown_ctx->shutdown_ctx; 5270 shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
5253 GNUNET_assert (shutdown_ctx != NULL); 5271 GNUNET_assert (shutdown_ctx != NULL);
5254 churn_ctx = (struct ChurnContext *)shutdown_ctx->cb_cls; 5272 churn_ctx = (struct ChurnContext *)shutdown_ctx->cb_cls;
5255 if (shutdown_ctx->outstanding > churn_ctx->pg->max_outstanding_connections) 5273 if (shutdown_ctx->outstanding > churn_ctx->pg->max_concurrent_ssh)
5256 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 5274 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
5257 (GNUNET_TIME_UNIT_MILLISECONDS, 100), 5275 (GNUNET_TIME_UNIT_MILLISECONDS, 100),
5258 &schedule_churn_shutdown_task, 5276 &schedule_churn_shutdown_task,
@@ -5602,7 +5620,7 @@ schedule_shutdown_task (void *cls,
5602 shutdown_ctx = peer_shutdown_ctx->shutdown_ctx; 5620 shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
5603 GNUNET_assert (shutdown_ctx != NULL); 5621 GNUNET_assert (shutdown_ctx != NULL);
5604 5622
5605 if (shutdown_ctx->outstanding > shutdown_ctx->pg->max_outstanding_connections) 5623 if (shutdown_ctx->outstanding > shutdown_ctx->pg->max_concurrent_ssh)
5606 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 5624 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
5607 (GNUNET_TIME_UNIT_MILLISECONDS, 100), 5625 (GNUNET_TIME_UNIT_MILLISECONDS, 100),
5608 &schedule_shutdown_task, peer_shutdown_ctx); 5626 &schedule_shutdown_task, peer_shutdown_ctx);