#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
}
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
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;
= GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT,
&start_fsm, d);
}
-
+#endif
/**
* Finite-state machine for starting GNUnet.
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)
{
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 ==
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;
}
#define VERBOSE_TESTING GNUNET_NO
-#define VERBOSE_TOPOLOGY GNUNET_YES
+#define VERBOSE_TOPOLOGY GNUNET_NO
#define DEBUG_CHURN GNUNET_NO
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;
/* 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);
#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);
"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);