From: Nathan S. Evans Date: Mon, 7 Mar 2011 10:47:42 +0000 (+0000) Subject: create nested directory structure for greater than 32k peers X-Git-Tag: initial-import-from-subversion-38251~19016 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e4dd537d1b8b66a750d963c6502c7f48e2e810a3;p=oweals%2Fgnunet.git create nested directory structure for greater than 32k peers --- diff --git a/src/testing/testing.c b/src/testing/testing.c index 8c50a2d91..e6671c99a 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -39,6 +39,7 @@ #define DEBUG_TESTING GNUNET_NO #define DEBUG_TESTING_RECONNECT GNUNET_YES +#define WAIT_FOR_HELLO GNUNET_NO /** * How long do we wait after starting gnunet-service-arm @@ -116,13 +117,16 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) } daemon->phase = SP_START_DONE; +#if WAIT_FOR_HELLO if (NULL != cb) /* FIXME: what happens when this callback calls GNUNET_TESTING_daemon_stop? */ cb (daemon->cb_cls, &daemon->id, daemon->cfg, daemon, NULL); +#endif } static void start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +#if WAIT_FOR_HELLO /** * Function called after GNUNET_CORE_connect has succeeded * (or failed for good). Note that the private key of the @@ -163,7 +167,7 @@ testing_init (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully started peer `%4s'.\n", GNUNET_i2s (my_identity)); #endif - d->id = *my_identity; + d->id = *my_identity; /* FIXME: shouldn't we already have this from reading the hostkey file? */ if (d->shortname == NULL) d->shortname = strdup (GNUNET_i2s (my_identity)); d->server = server; @@ -210,7 +214,7 @@ testing_init (void *cls, = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d); } - +#endif /** * Finite-state machine for starting GNUnet. @@ -618,6 +622,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (d->server != NULL) GNUNET_CORE_disconnect(d->server); +#if WAIT_FOR_HELLO if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0) { @@ -645,6 +650,34 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) d->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_CONSTANTS_SERVICE_RETRY, 2), &start_fsm, d); +#else + d->th = GNUNET_TRANSPORT_connect (d->cfg, &d->id, d, NULL, NULL, NULL); + if (d->th == NULL) + { + if (GNUNET_YES == d->dead) + GNUNET_TESTING_daemon_stop (d, + GNUNET_TIME_absolute_get_remaining + (d->max_timeout), d->dead_cb, + d->dead_cb_cls, GNUNET_YES, GNUNET_NO); + else if (NULL != d->cb) + d->cb (d->cb_cls, &d->id, d->cfg, d, + _("Failed to connect to transport service!\n")); + return; + } + #if DEBUG_TESTING + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Connected to transport service `%s', getting HELLO\n", + GNUNET_i2s (my_identity)); + #endif + + GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d); + cb = d->cb; + d->cb = NULL; + if (NULL != cb) /* FIXME: what happens when this callback calls GNUNET_TESTING_daemon_stop? */ + cb (d->cb_cls, &d->id, d->cfg, d, NULL); + d->running = GNUNET_YES; + d->phase = SP_GET_HELLO; +#endif break; case SP_GET_HELLO: if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == @@ -1945,6 +1978,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, if (NULL != cb) cb (cb_cls, &d1->id, &d2->id, 0, d1->cfg, d2->cfg, d1, d2, _("Peers are not fully running yet, can not connect!\n")); + GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Peers are not up!\n"); return; } diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 155acb156..fb6d9adda 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c @@ -32,7 +32,7 @@ #define VERBOSE_TESTING GNUNET_NO -#define VERBOSE_TOPOLOGY GNUNET_YES +#define VERBOSE_TOPOLOGY GNUNET_NO #define DEBUG_CHURN GNUNET_NO @@ -5704,6 +5704,7 @@ GNUNET_TESTING_daemons_start( struct GNUNET_DISK_FileHandle *fd; struct GNUNET_CONFIGURATION_Handle *pcfg; unsigned int off; + struct OutstandingSSH *ssh_entry; unsigned int hostcnt; unsigned int i; uint16_t minport; @@ -5816,13 +5817,13 @@ GNUNET_TESTING_daemons_start( /* Create the servicehome directory for each remote peer */ GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME", - &baseservicehome)); + &baseservicehome)); for (i = 0; i < pg->num_hosts; i++) { - struct OutstandingSSH *ssh_entry; ssh_entry = GNUNET_malloc(sizeof(struct OutstandingSSH)); ssh_entry->hostname = pg->hosts[i].hostname; /* Don't free! */ GNUNET_CONTAINER_DLL_insert(pg->ssh_head, pg->ssh_tail, ssh_entry); + GNUNET_asprintf(&tmpdir, "%s/%s", baseservicehome, pg->hosts[i].hostname); if (NULL != pg->hosts[i].username) GNUNET_asprintf (&arg, "%s@%s", pg->hosts[i].username, pg->hosts[i].hostname); @@ -5836,15 +5837,16 @@ GNUNET_TESTING_daemons_start( #if !DEBUG_TESTING "-q", #endif - arg, "mkdir -p", baseservicehome, + arg, "mkdir -p", tmpdir, NULL); } else proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, - "mkdir -p", baseservicehome, NULL); + "mkdir -p", tmpdir, NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating remote dir with command ssh %s %s %s\n", arg, - " mkdir -p ", baseservicehome); + " mkdir -p ", tmpdir); + GNUNET_free(tmpdir); GNUNET_free(arg); GNUNET_OS_process_wait (proc); GNUNET_OS_process_close(proc); @@ -5927,15 +5929,22 @@ GNUNET_TESTING_daemons_start( "SERVICEHOME", &baseservicehome)) { - GNUNET_asprintf (&newservicehome, "%s/%d/", baseservicehome, off); + if (hostname != NULL) + GNUNET_asprintf (&newservicehome, "%s/%s/%d/", baseservicehome, hostname, off); + else + GNUNET_asprintf (&newservicehome, "%s/%d/", baseservicehome, off); GNUNET_free (baseservicehome); } else { tmpdir = getenv ("TMPDIR"); tmpdir = tmpdir ? tmpdir : "/tmp"; - GNUNET_asprintf (&newservicehome, "%s/%s/%d/", tmpdir, - "gnunet-testing-test-test", off); + if (hostname != NULL) + GNUNET_asprintf (&newservicehome, "%s/%s/%s/%d/", tmpdir, hostname, + "gnunet-testing-test-test", off); + else + GNUNET_asprintf (&newservicehome, "%s/%s/%d/", tmpdir, + "gnunet-testing-test-test", off); } GNUNET_CONFIGURATION_set_value_string (pcfg, "PATHS", "SERVICEHOME", newservicehome);