From 2d1d94da00e8aa28c9db86462daf80ab58a3a660 Mon Sep 17 00:00:00 2001 From: Sree Harsha Totakura Date: Mon, 15 Apr 2013 12:04:27 +0000 Subject: - fixes --- src/testbed/test_testbed_api_controllerlink.c | 8 +++---- src/testbed/test_testbed_api_statistics.c | 2 +- src/testbed/testbed_api.c | 22 +++--------------- src/testbed/testbed_api.h | 5 ----- src/testbed/testbed_api_hosts.c | 32 +++++++++++++++++++++++++-- src/testbed/testbed_api_hosts.h | 12 ++++++++++ 6 files changed, 50 insertions(+), 31 deletions(-) diff --git a/src/testbed/test_testbed_api_controllerlink.c b/src/testbed/test_testbed_api_controllerlink.c index b640dea4c..b3e13f1ff 100644 --- a/src/testbed/test_testbed_api_controllerlink.c +++ b/src/testbed/test_testbed_api_controllerlink.c @@ -299,6 +299,10 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } if (NULL != hc_handle) GNUNET_TESTBED_is_host_habitable_cancel (hc_handle); + if (NULL != mc) + GNUNET_TESTBED_controller_disconnect (mc); + if (NULL != cp) + GNUNET_TESTBED_controller_stop (cp); if (NULL != slave3) GNUNET_TESTBED_host_destroy (slave3); if (NULL != slave2) @@ -307,14 +311,10 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_TESTBED_host_destroy (slave); if (NULL != host) GNUNET_TESTBED_host_destroy (host); - if (NULL != mc) - GNUNET_TESTBED_controller_disconnect (mc); if (NULL != cfg) GNUNET_CONFIGURATION_destroy (cfg); if (NULL != cfg3) GNUNET_CONFIGURATION_destroy (cfg3); - if (NULL != cp) - GNUNET_TESTBED_controller_stop (cp); if (NULL != rh) GNUNET_TESTBED_cancel_registration (rh); } diff --git a/src/testbed/test_testbed_api_statistics.c b/src/testbed/test_testbed_api_statistics.c index 82b85f700..bc01f6bc8 100644 --- a/src/testbed/test_testbed_api_statistics.c +++ b/src/testbed/test_testbed_api_statistics.c @@ -142,7 +142,7 @@ op_comp_cb (void *cls, GNUNET_TESTBED_operation_done (op); op = NULL; GNUNET_SCHEDULER_cancel (abort_task); - GNUNET_SCHEDULER_shutdown (); + GNUNET_SCHEDULER_shutdown (); } diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index 869fa2fad..49be33496 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c @@ -1335,7 +1335,7 @@ oprelease_get_slave_config (void *cls) * * @param host host to run the controller on; This should be the same host if * the controller was previously started with - * GNUNET_TESTBED_controller_start; NULL for localhost + * GNUNET_TESTBED_controller_start() * @param event_mask bit mask with set of events to call 'cc' for; * or-ed values of "1LL" shifted by the * respective 'enum GNUNET_TESTBED_EventType' @@ -1394,22 +1394,6 @@ GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host, GNUNET_TESTBED_controller_disconnect (controller); return NULL; } - if (NULL == host) - { - host = GNUNET_TESTBED_host_create_by_id_ (0, controller->cfg); - if (NULL == host) /* If the above host create fails */ - { - LOG (GNUNET_ERROR_TYPE_WARNING, - "Treating NULL host as localhost. Multiple references to localhost " - "may break when localhost freed before calling disconnect \n"); - host = GNUNET_TESTBED_host_lookup_by_id_ (0); - } - else - { - controller->aux_host = GNUNET_YES; - } - } - GNUNET_assert (NULL != host); GNUNET_TESTBED_mark_host_registered_at_ (host, controller); controller->host = host; controller->opq_parallel_operations = @@ -1503,9 +1487,9 @@ GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller } if (NULL != controller->client) GNUNET_CLIENT_disconnect (controller->client); + if (NULL != controller->host) + GNUNET_TESTBED_deregister_host_at_ (controller->host, controller); GNUNET_CONFIGURATION_destroy (controller->cfg); - if (GNUNET_YES == controller->aux_host) - GNUNET_TESTBED_host_destroy (controller->host); GNUNET_TESTBED_operation_queue_destroy_ (controller->opq_parallel_operations); GNUNET_TESTBED_operation_queue_destroy_ (controller->opq_parallel_service_connections); diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h index eea191256..7c7edff5f 100644 --- a/src/testbed/testbed_api.h +++ b/src/testbed/testbed_api.h @@ -274,11 +274,6 @@ struct GNUNET_TESTBED_Controller */ int in_receive; - /** - * Did we create the host for this? - */ - int aux_host; - /** * The operation id counter. use current value and increment */ diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c index e5b6d0a0b..0774c023e 100644 --- a/src/testbed/testbed_api_hosts.c +++ b/src/testbed/testbed_api_hosts.c @@ -805,6 +805,32 @@ GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host, } +/** + * Unmarks a host registered at a controller + * + * @param host the host to unmark + * @param controller the controller at which this host has to be unmarked + */ +void +GNUNET_TESTBED_deregister_host_at_ (struct GNUNET_TESTBED_Host *host, + const struct GNUNET_TESTBED_Controller + *const controller) +{ + struct RegisteredController *rc; + + for (rc = host->rc_head; NULL != rc; rc=rc->next) + if (controller == rc->controller) + break; + if (NULL == rc) + { + GNUNET_break (0); + return; + } + GNUNET_CONTAINER_DLL_remove (host->rc_head, host->rc_tail, rc); + GNUNET_free (rc); +} + + /** * Checks whether a host has been registered * @@ -1353,6 +1379,7 @@ call_cb: cb = h->cb; cb_cls = h->cb_cls; host = h->host; + free_argv (h->helper_argv); GNUNET_free (h); if (NULL != cb) cb (cb_cls, host, ret); @@ -1409,10 +1436,11 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host, stat_args[0] = "stat"; stat_args[2] = NULL; rsh_suffix_args = gen_rsh_suffix_args ((const char **) stat_args); + GNUNET_free (stat_args[1]); h->helper_argv = join_argv ((const char **) rsh_args, (const char **) rsh_suffix_args); - GNUNET_free (rsh_suffix_args); - GNUNET_free (rsh_args); + free_argv (rsh_suffix_args); + free_argv (rsh_args); h->auxp = GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ERR, NULL, NULL, h->helper_argv[0], h->helper_argv); diff --git a/src/testbed/testbed_api_hosts.h b/src/testbed/testbed_api_hosts.h index 6e2889eee..56cca624b 100644 --- a/src/testbed/testbed_api_hosts.h +++ b/src/testbed/testbed_api_hosts.h @@ -125,6 +125,18 @@ GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host, *controller); +/** + * Unmarks a host registered at a controller + * + * @param host the host to unmark + * @param controller the controller at which this host has to be unmarked + */ +void +GNUNET_TESTBED_deregister_host_at_ (struct GNUNET_TESTBED_Host *host, + const struct GNUNET_TESTBED_Controller + *const controller); + + /** * Checks whether a host has been registered with the given controller * -- cgit v1.2.3