From b9617164f8546d438717f49303c150bf13eb2d20 Mon Sep 17 00:00:00 2001 From: Sree Harsha Totakura Date: Fri, 27 Jul 2012 12:02:07 +0000 Subject: [PATCH] removed slave context --- src/testbed/gnunet-service-testbed.c | 48 ++++++++++------------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index 0b19d6e5c..6f7e38429 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c @@ -168,23 +168,6 @@ struct Slave }; -/** - * Slave startup context - */ -struct SlaveContext -{ - /** - * The slave corresponding to this context - */ - struct Slave *slave; - - /** - * The configuration used as a template while startup - */ - struct GNUNET_CONFIGURATION_Handle *cfg; -}; - - /** * States of LCFContext */ @@ -768,22 +751,20 @@ slave_status_callback (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, int status) { - struct SlaveContext *sc = cls; + struct Slave *slave = cls; if (GNUNET_SYSERR == status) { - sc->slave->controller_proc = NULL; + slave->controller_proc = NULL; LOG (GNUNET_ERROR_TYPE_WARNING, "Unexpected slave shutdown\n"); GNUNET_SCHEDULER_shutdown (); /* We too shutdown */ return; } - GNUNET_CONFIGURATION_destroy (sc->cfg); - sc->slave->controller = - GNUNET_TESTBED_controller_connect (cfg, host_list[sc->slave->host_id], + slave->controller = + GNUNET_TESTBED_controller_connect (cfg, host_list[slave->host_id], master_context->event_mask, - &slave_event_callback, sc->slave); - GNUNET_free (sc); + &slave_event_callback, slave); } @@ -1023,7 +1004,6 @@ handle_link_controllers (void *cls, { const struct GNUNET_TESTBED_ControllerLinkMessage *msg; struct GNUNET_CONFIGURATION_Handle *cfg; - struct SlaveContext *sc; struct LCFContextQueue *lcfq; struct Route *route; struct Route *new_route; @@ -1125,19 +1105,23 @@ handle_link_controllers (void *cls, return; } slave = GNUNET_malloc (sizeof (struct Slave)); - slave->host_id = delegated_host_id; - slave_list_add (slave); - sc = GNUNET_malloc (sizeof (struct SlaveContext)); - sc->slave = slave; - sc->cfg = cfg; + slave->host_id = delegated_host_id; + slave_list_add (slave); if (1 == msg->is_subordinate) { slave->controller_proc = GNUNET_TESTBED_controller_start (master_context->master_ip, host_list[slave->host_id], cfg, &slave_status_callback, - sc); - } + slave); + } + else { + slave->controller = + GNUNET_TESTBED_controller_connect (cfg, host_list[slave->host_id], + master_context->event_mask, + &slave_event_callback, slave); + } + GNUNET_CONFIGURATION_destroy (cfg); new_route = GNUNET_malloc (sizeof (struct Route)); new_route->dest = delegated_host_id; new_route->thru = master_context->host_id; -- 2.25.1