/*
This file is part of GNUnet.
- Copyright (C) 2010-2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2010-2013 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
* @file ats-tests/ats-testing.c
struct GNUNET_ATS_TEST_Topology *top;
+
/**
* Shutdown nicely
*
* @param cls NULL
- * @param tc the task context
*/
static void
-do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_shutdown (void *cls)
{
int c_m;
int c_s;
int c_op;
struct BenchmarkPeer *p;
- top->shutdown_task = NULL;
top->state.benchmarking = GNUNET_NO;
GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n"));
if (me->core_slave_connections == top->num_slaves)
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Master [%u] connected all slaves\n",
- me->no);
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Master [%u] connected all slaves\n",
+ me->no);
}
completed = GNUNET_YES;
for (c = 0; c < top->num_masters; c++)
}
if (GNUNET_YES == completed)
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "All master peers connected all slave peers\n", id,
- GNUNET_i2s (peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "All master peers connected all slave peers\n");
top->state.connected_CORE = GNUNET_YES;
/* Notify about setup done */
if (NULL != top->done_cb)
static void *
-transport_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
+transport_connect_adapter (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct BenchmarkPeer *me = cls;
return me->th;
}
+
static void
transport_disconnect_adapter (void *cls, void *op_result)
{
static void
-connect_completion_callback (void *cls, struct GNUNET_TESTBED_Operation *op,
- const char *emsg)
+connect_completion_callback (void *cls,
+ struct GNUNET_TESTBED_Operation *op,
+ const char *emsg)
{
struct TestbedConnectOperation *cop = cls;
static int ops = 0;
if (NULL == emsg)
{
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- _("Connected master [%u] with slave [%u]\n"), cop->master->no,
- cop->slave->no);
+ _("Connected master [%u] with slave [%u]\n"),
+ cop->master->no,
+ cop->slave->no);
}
else
{
_("Failed to connect master peer [%u] with slave [%u]\n"),
cop->master->no, cop->slave->no);
GNUNET_break(0);
- if (NULL != top->shutdown_task)
- GNUNET_SCHEDULER_cancel (top->shutdown_task);
- top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
+ GNUNET_SCHEDULER_shutdown ();
}
GNUNET_TESTBED_operation_done (op);
ops++;
}
}
+
static void
-do_connect_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_connect_peers (void *cls)
{
int c_m;
int c_s;
_("Could not connect master [%u] and slave [%u]\n"), p->no,
top->sps[c_s].no);
GNUNET_break(0);
- if (NULL != top->shutdown_task)
- GNUNET_SCHEDULER_cancel (top->shutdown_task);
- top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
+ GNUNET_SCHEDULER_shutdown ();
return;
}
}
static void
-comm_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
- void *ca_result, const char *emsg)
+comm_connect_completion_cb (void *cls,
+ struct GNUNET_TESTBED_Operation *op,
+ void *ca_result,
+ const char *emsg)
{
static int comm_done = 0;
+
if ((NULL != emsg) || (NULL == ca_result))
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initialization failed, shutdown\n"));
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Initialization failed, shutdown\n");
GNUNET_break(0);
- if (NULL != top->shutdown_task)
- GNUNET_SCHEDULER_cancel (top->shutdown_task);
- top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
+ GNUNET_SCHEDULER_shutdown ();
return;
}
comm_done++;
}
}
+
static void
-do_comm_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_comm_connect (void *cls)
{
int c_s;
int c_m;
{
struct BenchmarkPeer *me = cls;
struct BenchmarkPartner *p;
- int c_a;
int log;
char *peer_id;
+ if (NULL == address)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer %u: ATS Service disconnected!\n",
+ me->no);
+ return;
+ }
+
p = find_partner (me, &address->peer);
if (NULL == p)
{
if ((NULL != emsg) || (NULL == ca_result))
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initialization failed, shutdown\n"));
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Initialization failed, shutdown\n");
GNUNET_break(0);
- if (NULL != top->shutdown_task)
- GNUNET_SCHEDULER_cancel (top->shutdown_task);
- top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
+ GNUNET_SCHEDULER_shutdown ();
return;
}
op_done++;
static void
-do_connect_ats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_connect_ats (void *cls)
{
int c_m;
int c_s;
{
int c_m;
int c_s;
+
GNUNET_assert(NULL == cls);
GNUNET_assert(top->num_masters + top->num_slaves == num_peers);
GNUNET_assert(NULL != peers_);
- top->shutdown_task = GNUNET_SCHEDULER_add_delayed (
- GNUNET_TIME_UNIT_FOREVER_REL, &do_shutdown, top);
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+ top);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting up %u masters and %u slaves\n",
- top->num_masters, top->num_slaves);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Setting up %u masters and %u slaves\n",
+ top->num_masters,
+ top->num_slaves);
/* Setup master peers */
for (c_m = 0; c_m < top->num_masters; c_m++)
*/
static void
controller_event_cb (void *cls,
- const struct GNUNET_TESTBED_EventInformation *event)
+ const struct GNUNET_TESTBED_EventInformation *event)
{
- struct GNUNET_ATS_TEST_Topology *top = cls;
switch (event->type)
{
case GNUNET_TESTBED_ET_CONNECT:
break;
default:
GNUNET_break(0);
- GNUNET_SCHEDULER_cancel (top->shutdown_task);
- top->shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL );
+ GNUNET_SCHEDULER_shutdown ();
}
}
+
struct BenchmarkPeer *
GNUNET_ATS_TEST_get_peer (int src)
{
return &top->mps[src];
}
+
struct BenchmarkPartner *
GNUNET_ATS_TEST_get_partner (int src, int dest)
{