+ if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
+ GNUNET_SCHEDULER_cancel (shutdown_task);
+ shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
+}
+
+
+
+
+
+/**
+ * Functions of this signature are called when a peer has been successfully
+ * started or stopped.
+ *
+ * @param cls the closure from GNUNET_TESTBED_peer_start/stop()
+ * @param emsg NULL on success; otherwise an error description
+ */
+static void
+peer_churn_cb (void *cls, const char *emsg)
+{
+ struct DLLOperation *dll_op = cls;
+ struct GNUNET_TESTBED_Operation *op;
+ static unsigned int started_peers;
+
+ op = dll_op->op;
+ GNUNET_CONTAINER_DLL_remove (dll_op_head, dll_op_tail, dll_op);
+ GNUNET_free (dll_op);
+ if (NULL != emsg)
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ _("An operation has failed while starting peers\n"));
+ GNUNET_TESTBED_operation_done (op);
+ GNUNET_SCHEDULER_cancel (abort_task);
+ abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL);
+ return;
+ }
+ GNUNET_TESTBED_operation_done (op);
+ if (++started_peers == num_peers)
+ {
+ prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time);
+ printf ("%u peers started successfully in %.2f seconds\n",
+ num_peers, ((double) prof_time.rel_value) / 1000.00);
+ fflush (stdout);
+ result = GNUNET_OK;
+ if ((0 == num_links) && (topology == GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI))
+ {
+ shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
+ return;
+ }
+ state = STATE_PEERS_LINKING;
+ /* Do overlay connect */
+ prof_start_time = GNUNET_TIME_absolute_get ();
+ switch (topology)
+ {
+ case GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI:
+ topology_op =
+ GNUNET_TESTBED_overlay_configure_topology (NULL, num_peers, peers,
+ topology,
+ num_links,
+ GNUNET_TESTBED_TOPOLOGY_DISABLE_AUTO_RETRY,
+ GNUNET_TESTBED_TOPOLOGY_OPTION_END);
+ break;
+ case GNUNET_TESTBED_TOPOLOGY_CLIQUE:
+ topology_op =
+ GNUNET_TESTBED_overlay_configure_topology (NULL, num_peers, peers,
+ topology,
+ GNUNET_TESTBED_TOPOLOGY_DISABLE_AUTO_RETRY,
+ GNUNET_TESTBED_TOPOLOGY_OPTION_END);
+ num_links = num_peers * (num_peers - 1);
+ break;
+ default:
+ GNUNET_assert (0);
+ }
+ }