aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_group.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2011-02-15 16:28:07 +0000
committerNathan S. Evans <evans@in.tum.de>2011-02-15 16:28:07 +0000
commitbffca0da11f7b2b878998b4146adfa0a13c151ed (patch)
treec4c41315b437e24dacf243afba15f00b06c81d52 /src/testing/testing_group.c
parentf35db2c258aa7bc869473de13085bfaca9520ab9 (diff)
downloadgnunet-bffca0da11f7b2b878998b4146adfa0a13c151ed.tar.gz
gnunet-bffca0da11f7b2b878998b4146adfa0a13c151ed.zip
ssh per host
Diffstat (limited to 'src/testing/testing_group.c')
-rw-r--r--src/testing/testing_group.c108
1 files changed, 106 insertions, 2 deletions
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index b4420115d..7b851f708 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -363,6 +363,23 @@ struct ChurnRestartContext
363 struct GNUNET_TIME_Relative timeout; 363 struct GNUNET_TIME_Relative timeout;
364}; 364};
365 365
366struct OutstandingSSH
367{
368 struct OutstandingSSH *next;
369
370 struct OutstandingSSH *prev;
371
372 /**
373 * Number of current ssh connections.
374 */
375 uint32_t outstanding;
376
377 /**
378 * The hostname of this peer.
379 */
380 const char *hostname;
381};
382
366/** 383/**
367 * Data we keep per peer. 384 * Data we keep per peer.
368 */ 385 */
@@ -673,6 +690,18 @@ struct GNUNET_TESTING_PeerGroup
673 * Hostkeys loaded from a file. 690 * Hostkeys loaded from a file.
674 */ 691 */
675 char *hostkey_data; 692 char *hostkey_data;
693
694 /**
695 * Head of DLL to keep track of the number of outstanding
696 * ssh connections per peer.
697 */
698 struct OutstandingSSH *ssh_head;
699
700 /**
701 * Tail of DLL to keep track of the number of outstanding
702 * ssh connections per peer.
703 */
704 struct OutstandingSSH *ssh_tail;
676}; 705};
677 706
678struct UpdateContext 707struct UpdateContext
@@ -2777,6 +2806,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
2777 GNUNET_OS_start_process (NULL, NULL, "scp", "scp", mytemp, arg, 2806 GNUNET_OS_start_process (NULL, NULL, "scp", "scp", mytemp, arg,
2778 NULL); 2807 NULL);
2779 2808
2809 GNUNET_OS_process_wait(procarr[pg_iter]); /* FIXME: add scheduled blacklist file copy that parallelizes file copying! */
2810
2780#if VERBOSE_TESTING 2811#if VERBOSE_TESTING
2781 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2812 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2782 _("Copying file with command scp %s %s\n"), mytemp, 2813 _("Copying file with command scp %s %s\n"), mytemp,
@@ -4565,6 +4596,63 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
4565} 4596}
4566 4597
4567/** 4598/**
4599 * Lookup and return the number of SSH connections to a host.
4600 *
4601 * @param hostname the hostname to lookup in the list
4602 * @param pg the peergroup that the host belongs to
4603 *
4604 * @return the number of current ssh connections to the host
4605 */
4606static unsigned int
4607count_outstanding_at_host(const char *hostname, struct GNUNET_TESTING_PeerGroup *pg)
4608{
4609 struct OutstandingSSH *pos;
4610 pos = pg->ssh_head;
4611 while ((pos != NULL) && (strcmp(pos->hostname, hostname) != 0))
4612 pos = pos->next;
4613 GNUNET_assert(pos != NULL);
4614 return pos->outstanding;
4615}
4616
4617
4618/**
4619 * Increment the number of SSH connections to a host by one.
4620 *
4621 * @param hostname the hostname to lookup in the list
4622 * @param pg the peergroup that the host belongs to
4623 *
4624 */
4625static void
4626increment_outstanding_at_host(const char *hostname, struct GNUNET_TESTING_PeerGroup *pg)
4627{
4628 struct OutstandingSSH *pos;
4629 pos = pg->ssh_head;
4630 while ((pos != NULL) && (strcmp(pos->hostname, hostname) != 0))
4631 pos = pos->next;
4632 GNUNET_assert(pos != NULL);
4633 pos->outstanding++;
4634}
4635
4636/**
4637 * Decrement the number of SSH connections to a host by one.
4638 *
4639 * @param hostname the hostname to lookup in the list
4640 * @param pg the peergroup that the host belongs to
4641 *
4642 */
4643static void
4644decrement_outstanding_at_host(const char *hostname, struct GNUNET_TESTING_PeerGroup *pg)
4645{
4646 struct OutstandingSSH *pos;
4647 pos = pg->ssh_head;
4648 while ((pos != NULL) && (strcmp(pos->hostname, hostname) != 0))
4649 pos = pos->next;
4650 GNUNET_assert(pos != NULL);
4651 pos->outstanding--;
4652}
4653
4654
4655/**
4568 * Callback that is called whenever a hostkey is generated 4656 * Callback that is called whenever a hostkey is generated
4569 * for a peer. Call the real callback and decrement the 4657 * for a peer. Call the real callback and decrement the
4570 * starting counter for the peergroup. 4658 * starting counter for the peergroup.
@@ -4582,6 +4670,8 @@ internal_hostkey_callback (void *cls,
4582 struct InternalStartContext *internal_context = cls; 4670 struct InternalStartContext *internal_context = cls;
4583 internal_context->peer->pg->starting--; 4671 internal_context->peer->pg->starting--;
4584 internal_context->peer->pg->started++; 4672 internal_context->peer->pg->started++;
4673 if (internal_context->hostname != NULL)
4674 decrement_outstanding_at_host(internal_context->hostname, internal_context->peer->pg);
4585 if (internal_context->hostkey_callback != NULL) 4675 if (internal_context->hostkey_callback != NULL)
4586 internal_context->hostkey_callback (internal_context->hostkey_cls, id, d, 4676 internal_context->hostkey_callback (internal_context->hostkey_cls, id, d,
4587 emsg); 4677 emsg);
@@ -4628,8 +4718,12 @@ internal_continue_startup (void *cls,
4628 return; 4718 return;
4629 } 4719 }
4630 4720
4631 if (internal_context->peer->pg->starting < internal_context->peer->pg->max_concurrent_ssh) 4721 if ((internal_context->peer->pg->starting < internal_context->peer->pg->max_concurrent_ssh) ||
4722 ((internal_context->hostname != NULL) &&
4723 (count_outstanding_at_host(internal_context->hostname, internal_context->peer->pg) < internal_context->peer->pg->max_concurrent_ssh)))
4632 { 4724 {
4725 if (internal_context->hostname != NULL)
4726 increment_outstanding_at_host(internal_context->hostname, internal_context->peer->pg);
4633 internal_context->peer->pg->starting++; 4727 internal_context->peer->pg->starting++;
4634 GNUNET_TESTING_daemon_continue_startup (internal_context->peer->daemon); 4728 GNUNET_TESTING_daemon_continue_startup (internal_context->peer->daemon);
4635 } 4729 }
@@ -4725,6 +4819,8 @@ schedule_churn_restart (void *cls,
4725 } 4819 }
4726} 4820}
4727 4821
4822
4823
4728static void 4824static void
4729internal_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 4825internal_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
4730{ 4826{
@@ -4735,8 +4831,12 @@ internal_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
4735 return; 4831 return;
4736 } 4832 }
4737 4833
4738 if (internal_context->peer->pg->starting < internal_context->peer->pg->max_concurrent_ssh) 4834 if ((internal_context->peer->pg->starting < internal_context->peer->pg->max_concurrent_ssh) ||
4835 ((internal_context->hostname != NULL) &&
4836 (count_outstanding_at_host(internal_context->hostname, internal_context->peer->pg) < internal_context->peer->pg->max_concurrent_ssh)))
4739 { 4837 {
4838 if (internal_context->hostname != NULL)
4839 increment_outstanding_at_host(internal_context->hostname, internal_context->peer->pg);
4740 internal_context->peer->pg->starting++; 4840 internal_context->peer->pg->starting++;
4741 internal_context->peer->daemon = 4841 internal_context->peer->daemon =
4742 GNUNET_TESTING_daemon_start (internal_context->peer->cfg, 4842 GNUNET_TESTING_daemon_start (internal_context->peer->cfg,
@@ -4953,6 +5053,10 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
4953 &baseservicehome)); 5053 &baseservicehome));
4954 for (i = 0; i < pg->num_hosts; i++) 5054 for (i = 0; i < pg->num_hosts; i++)
4955 { 5055 {
5056 struct OutstandingSSH *ssh_entry;
5057 ssh_entry = GNUNET_malloc(sizeof(struct OutstandingSSH));
5058 ssh_entry->hostname = pg->hosts[i].hostname; /* Don't free! */
5059 GNUNET_CONTAINER_DLL_insert(pg->ssh_head, pg->ssh_tail, ssh_entry);
4956 if (NULL != pg->hosts[i].username) 5060 if (NULL != pg->hosts[i].username)
4957 GNUNET_asprintf (&arg, "%s@%s", pg->hosts[i].username, pg->hosts[i].hostname); 5061 GNUNET_asprintf (&arg, "%s@%s", pg->hosts[i].username, pg->hosts[i].hostname);
4958 else 5062 else