*/
#define DEFAULT_SETUP_TIMEOUT 300
+/**
+ * Testbed Run Handle
+ */
+struct RunContext;
+
/**
* Context information for the operation we start
*/
};
+/**
+ * Context for host compability checks
+ */
+struct CompatibilityCheckContext
+{
+ /**
+ * The run context
+ */
+ struct RunContext *rc;
+
+ /**
+ * Handle for the compability check
+ */
+ struct GNUNET_TESTBED_HostHabitableCheckHandle *h;
+
+ /**
+ * Index of the host in the run context's hosts array
+ */
+ unsigned int index;
+};
+
+
/**
* Testbed Run Handle
*/
struct GNUNET_TESTBED_Host **hosts;
/**
- * The handle for whether a host is habitable or not
+ * Array of compatibility check contexts
*/
- struct GNUNET_TESTBED_HostHabitableCheckHandle **hc_handles;
+ struct CompatibilityCheckContext *hclist;
/**
* Array of peers which we create
GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rc->register_hosts_task);
GNUNET_assert (NULL == rc->reg_handle);
GNUNET_assert (NULL == rc->peers);
- GNUNET_assert (NULL == rc->hc_handles);
+ GNUNET_assert (NULL == rc->hclist);
GNUNET_assert (RC_PEERS_SHUTDOWN == rc->state);
GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap32_size (rc->rcop_map));
GNUNET_CONTAINER_multihashmap32_destroy (rc->rcop_map);
static void
cleanup (struct RunContext *rc)
{
+ struct CompatibilityCheckContext *hc;
unsigned int nhost;
- if (NULL != rc->hc_handles)
+ if (NULL != rc->hclist)
{
for (nhost = 0; nhost < rc->num_hosts; nhost++)
- if (NULL != rc->hc_handles[nhost])
- GNUNET_TESTBED_is_host_habitable_cancel (rc->hc_handles[nhost]);
- GNUNET_free (rc->hc_handles);
- rc->hc_handles = NULL;
+ {
+ hc = &rc->hclist[nhost];
+ if (NULL != hc->h)
+ GNUNET_TESTBED_is_host_habitable_cancel (hc->h);
+ }
+ GNUNET_free (rc->hclist);
+ rc->hclist = NULL;
}
/* Stop register hosts task if it is running */
if (GNUNET_SCHEDULER_NO_TASK != rc->register_hosts_task)
host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *host,
int status)
{
- struct RunContext *rc = cls;
+ struct CompatibilityCheckContext *hc = cls;
+ struct RunContext *rc;
struct GNUNET_TESTBED_Host **old_hosts;
unsigned int nhost;
- for (nhost = 0; nhost < rc->num_hosts; nhost++)
- {
- if (host == rc->hosts[nhost])
- break;
- }
- GNUNET_assert (nhost != rc->num_hosts);
- rc->hc_handles[nhost] = NULL;
+ GNUNET_assert (NULL != (rc = hc->rc));
+ nhost = hc->index;
+ GNUNET_assert (nhost <= rc->num_hosts);
+ GNUNET_assert (host == rc->hosts[nhost]);
+ hc->h = NULL;
if (GNUNET_NO == status)
{
if ((NULL != host) && (NULL != GNUNET_TESTBED_host_get_hostname (host)))
rc->reg_hosts++;
if (rc->reg_hosts < rc->num_hosts)
return;
- GNUNET_free (rc->hc_handles);
- rc->hc_handles = NULL;
+ GNUNET_free (rc->hclist);
+ rc->hclist = NULL;
rc->h = rc->hosts[0];
rc->num_hosts--;
if (0 < rc->num_hosts)
GNUNET_free (rc->hosts);
rc->hosts = NULL;
}
+ GNUNET_TESTBED_host_resolve_ (rc->h);
+ for (nhost = 0; nhost < rc->num_hosts; nhost++)
+ GNUNET_TESTBED_host_resolve_ (rc->hosts[nhost]);
GNUNET_OS_network_interfaces_list (netint_proc, rc);
if (NULL == rc->trusted_ip)
rc->trusted_ip = GNUNET_strdup ("127.0.0.1");
{
struct RunContext *rc;
char *topology;
+ struct CompatibilityCheckContext *hc;
struct GNUNET_TIME_Relative timeout;
unsigned long long random_links;
unsigned int hid;
}
if (0 != rc->num_hosts)
{
- rc->hc_handles =
- GNUNET_malloc (sizeof (struct GNUNET_TESTBED_HostHabitableCheckHandle *)
- * rc->num_hosts);
+ rc->hclist = GNUNET_malloc (sizeof (struct CompatibilityCheckContext)
+ * rc->num_hosts);
for (nhost = 0; nhost < rc->num_hosts; nhost++)
{
- if (NULL ==
- (rc->hc_handles[nhost] =
- GNUNET_TESTBED_is_host_habitable (rc->hosts[nhost], rc->cfg,
- &host_habitable_cb, rc)))
+ hc = &rc->hclist[nhost];
+ hc->index = nhost;
+ hc->rc = rc;
+ hc->h = GNUNET_TESTBED_is_host_habitable (rc->hosts[nhost], rc->cfg,
+ &host_habitable_cb, hc);
+ if (NULL == hc->h)
{
GNUNET_break (0);
for (nhost = 0; nhost < rc->num_hosts; nhost++)
- if (NULL != rc->hc_handles[nhost])
- GNUNET_TESTBED_is_host_habitable_cancel (rc->hc_handles[nhost]);
- GNUNET_free (rc->hc_handles);
- rc->hc_handles = NULL;
+ {
+ hc = &rc->hclist[nhost];
+ if (NULL != hc->h)
+ GNUNET_TESTBED_is_host_habitable_cancel (hc->h);
+ }
+ GNUNET_free (rc->hclist);
+ rc->hclist = NULL;
goto error_cleanup;
}
}