*/
RC_LINKED,
+ /**
+ * Peers are created
+ */
+ RC_PEERS_CREATED,
+
/**
* The testbed run is ready and the master callback can be called now. At this
* time the peers are all started and if a topology is provided in the
*/
unsigned int num_peers;
- /**
- * counter to count overlay connect attempts. This counter includes both
- * successful and failed overlay connects
- */
- unsigned int oc_count;
-
/**
* Expected overlay connects. Should be zero if no topology is relavant
*/
if (rc->peer_count < rc->num_peers)
return;
DEBUG ("%u peers created in %s\n", rc->num_peers, prof_time (rc));
+ rc->state = RC_PEERS_CREATED;
GNUNET_SCHEDULER_add_now (&start_peers_task, rc);
}
}
+/**
+ * Callbacks of this type are called when topology configuration is completed
+ *
+ * @param cls the operation closure given to
+ * GNUNET_TESTBED_overlay_configure_topology_va() and
+ * GNUNET_TESTBED_overlay_configure() calls
+ * @param nsuccess the number of successful overlay connects
+ * @param nfailures the number of overlay connects which failed
+ */
+static void
+topology_completion_callback (void *cls, unsigned int nsuccess,
+ unsigned int nfailures)
+{
+ struct RunContext *rc = cls;
+
+ rc->state = RC_READY;
+ GNUNET_SCHEDULER_add_continuation (&call_master, rc,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+}
+
+
/**
* Function to create peers
*
return;
}
}
- if (NULL != rc->topology_operation)
- {
- switch (event->type)
- {
- case GNUNET_TESTBED_ET_OPERATION_FINISHED:
- case GNUNET_TESTBED_ET_CONNECT:
- rc->oc_count++;
- break;
- default:
- GNUNET_break (0);
- shutdown_now (rc);
- return;
- }
- if (rc->oc_count == rc->num_oc)
- {
- rc->state = RC_READY;
- GNUNET_SCHEDULER_add_continuation (&call_master, rc,
- GNUNET_SCHEDULER_REASON_PREREQ_DONE);
- }
- goto call_cc;
- }
for (dll_op = rc->dll_op_head; NULL != dll_op; dll_op = dll_op->next)
{
if ((GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type) &&
return;
switch (rc->state)
{
- case RC_LINKED:
+ case RC_PEERS_CREATED:
case RC_READY:
rc->state = RC_PEERS_STOPPED;
DEBUG ("Peers stopped in %s\n", prof_time (rc));
rc->topology_operation =
GNUNET_TESTBED_overlay_configure_topology (NULL, rc->num_peers,
rc->peers, &rc->num_oc,
+ &topology_completion_callback,
+ rc,
rc->topology,
rc->random_links,
GNUNET_TESTBED_TOPOLOGY_OPTION_END);
rc->topology_operation =
GNUNET_TESTBED_overlay_configure_topology (NULL, rc->num_peers,
rc->peers, &rc->num_oc,
+ &topology_completion_callback,
+ rc,
rc->topology,
rc->topo_file,
GNUNET_TESTBED_TOPOLOGY_OPTION_END);
rc->topology_operation =
GNUNET_TESTBED_overlay_configure_topology (NULL, rc->num_peers,
rc->peers, &rc->num_oc,
+ &topology_completion_callback,
+ rc,
rc->topology,
GNUNET_TESTBED_TOPOLOGY_OPTION_END);
if (NULL == rc->topology_operation)
int status)
{
struct RunContext *rc = cls;
+ struct GNUNET_TESTBED_Host **old_hosts;
unsigned int nhost;
for (nhost = 0; nhost < rc->num_hosts; nhost++)
rc->h = rc->hosts[0];
rc->num_hosts--;
if (0 < rc->num_hosts)
- rc->hosts = &rc->hosts[1];
+ {
+ old_hosts = rc->hosts;
+ rc->hosts =
+ GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Host *) * rc->num_hosts);
+ memcpy (rc->hosts, &old_hosts[1],
+ (sizeof (struct GNUNET_TESTBED_Host *) * rc->num_hosts));
+ GNUNET_free (old_hosts);
+ }
else
{
GNUNET_free (rc->hosts);