static struct GNUNET_TESTING_Daemon *last;
+/**
+ * Active connection attempt.
+ */
+struct GNUNET_TESTING_ConnectContext *cc[NUM_PEERS];
+
/**
* Check whether peers successfully shut down.
*/
static void
clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ unsigned int i;
+
+ for (i = 0; i < NUM_PEERS; i++)
+ {
+ if (NULL != cc[i])
+ {
+ GNUNET_TESTING_daemons_connect_cancel (cc[i]);
+ cc[i] = NULL;
+ }
+ }
GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
ok = 0;
}
struct GNUNET_TESTING_Daemon *second_daemon,
const char *emsg)
{
+ struct GNUNET_TESTING_ConnectContext **cc = cls;
+ unsigned int i;
+
+ *cc = NULL;
if (NULL != emsg)
{
- fprintf (stderr, "Failed to connect two peers: %s\n", emsg);
+ FPRINTF (stderr, "Failed to connect two peers: %s\n", emsg);
+ for (i = 0; i < NUM_PEERS; i++)
+ if (NULL != cc[i])
+ {
+ GNUNET_TESTING_daemons_connect_cancel (cc[i]);
+ cc[i] = NULL;
+ }
GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
GNUNET_assert (0);
return;
last = d;
return;
}
- GNUNET_TESTING_daemons_connect (last, d, TIMEOUT, CONNECT_ATTEMPTS,
- GNUNET_YES, ¬ify_connect_complete, NULL);
+ cc[peers_left] =
+ GNUNET_TESTING_daemons_connect (last, d, TIMEOUT, CONNECT_ATTEMPTS,
+ GNUNET_YES, ¬ify_connect_complete,
+ &cc[peers_left]);
if (peers_left == 0)
{
/* close circle */
- GNUNET_TESTING_daemons_connect (d, first, TIMEOUT, CONNECT_ATTEMPTS,
- GNUNET_YES, ¬ify_connect_complete, NULL);
+ cc[NUM_PEERS - 1] =
+ GNUNET_TESTING_daemons_connect (d, first, TIMEOUT, CONNECT_ATTEMPTS,
+ GNUNET_YES, ¬ify_connect_complete,
+ &cc[NUM_PEERS - 1]);
}
}