From 251c9287514c0e3a2cf6a3f6f978a27a49e65085 Mon Sep 17 00:00:00 2001 From: Sree Harsha Totakura Date: Thu, 27 Oct 2016 13:00:37 +0000 Subject: [PATCH] Fix #4718: Do not echo BARRIER_STATUS messages back to the main controller/test driverAlso add a few FIXMEs to be fixed and fix testcase logic to accommodate new scheduler shutdown semantics --- src/testbed/gnunet-service-testbed_barriers.c | 16 +++---- src/testbed/test_testbed_api_barriers.c | 44 ++++++++++++------- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/testbed/gnunet-service-testbed_barriers.c b/src/testbed/gnunet-service-testbed_barriers.c index 831bc3c6d..638263103 100644 --- a/src/testbed/gnunet-service-testbed_barriers.c +++ b/src/testbed/gnunet-service-testbed_barriers.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2008--2013 GNUnet e.V. + Copyright (C) 2008--2016 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 @@ -234,7 +234,7 @@ remove_barrier (struct Barrier *barrier) GNUNET_CONTAINER_DLL_remove (barrier->head, barrier->tail, ctx); - GNUNET_free (ctx); + ctx->barrier = NULL; } GNUNET_free (barrier->name); GNUNET_free (barrier); @@ -546,6 +546,8 @@ wbarrier_status_cb (void *cls, struct WBarrier *wrapper = cls; struct Barrier *barrier = wrapper->barrier; + //FIXME: why are we removing the wrapper? They should only be removed if they + //barrier is crossed or errored out GNUNET_assert (b_ == wrapper->hbarrier); wrapper->hbarrier = NULL; GNUNET_CONTAINER_DLL_remove (barrier->whead, @@ -713,6 +715,7 @@ handle_barrier_init (void *cls, GNUNET_CONTAINER_DLL_insert_tail (barrier->whead, barrier->wtail, wrapper); + //FIXME: Increment barrier->num_wbarriers wrapper->hbarrier = GNUNET_TESTBED_barrier_init_ (slave->controller, barrier->name, barrier->quorum, @@ -898,16 +901,13 @@ handle_barrier_status (void *cls, return; } GNUNET_SERVICE_client_continue (client); - while (NULL != (client_ctx = barrier->head)) /* Notify peers */ + for(client_ctx = barrier->head; NULL != client_ctx; client_ctx = client_ctx->next) /* Notify peers */ { env = GNUNET_MQ_msg_copy (&msg->header); - GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), + GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client_ctx->client), env); - GNUNET_CONTAINER_DLL_remove (barrier->head, - barrier->tail, - client_ctx); - client_ctx->barrier = NULL; } + //FIXME: Send status to wrappers if they exist } /* end of gnunet-service-testbed_barriers.c */ diff --git a/src/testbed/test_testbed_api_barriers.c b/src/testbed/test_testbed_api_barriers.c index 01c745a75..e712e2d5a 100644 --- a/src/testbed/test_testbed_api_barriers.c +++ b/src/testbed/test_testbed_api_barriers.c @@ -50,7 +50,7 @@ struct GNUNET_TESTBED_Barrier *barrier; /** * Identifier for the shutdown task */ -static struct GNUNET_SCHEDULER_Task *shutdown_task; +static struct GNUNET_SCHEDULER_Task *timeout_task; /** * Result of this test case @@ -59,20 +59,30 @@ static int result; /** - * Shutdown this test case when it takes too long - * - * @param cls NULL + * Handle SIGINT and SIGTERM */ static void -do_shutdown (void *cls) +shutdown_handler(void *cls) { - shutdown_task = NULL; - if (NULL != barrier) + if (NULL != timeout_task) { - GNUNET_TESTBED_barrier_cancel (barrier); - barrier = NULL; + GNUNET_SCHEDULER_cancel(timeout_task); + timeout_task = NULL; } +} + +/** + * Shutdown this test case when it takes too long + * + * @param cls NULL + */ +static void +do_timeout (void *cls) +{ + timeout_task = NULL; + if (barrier != NULL) + GNUNET_TESTBED_barrier_cancel (barrier); GNUNET_SCHEDULER_shutdown (); } @@ -112,20 +122,19 @@ barrier_cb (void *cls, LOG (GNUNET_ERROR_TYPE_ERROR, "Barrier initialisation failed: %s", (NULL == emsg) ? "unknown reason" : emsg); - barrier = NULL; - GNUNET_SCHEDULER_shutdown (); - return; + break; case GNUNET_TESTBED_BARRIERSTATUS_CROSSED: LOG (GNUNET_ERROR_TYPE_INFO, "Barrier crossed\n"); if (old_status == GNUNET_TESTBED_BARRIERSTATUS_INITIALISED) result = GNUNET_OK; - barrier = NULL; - GNUNET_SCHEDULER_shutdown (); - return; + break; default: GNUNET_assert (0); + return; } + barrier = NULL; + GNUNET_SCHEDULER_shutdown (); } @@ -165,11 +174,12 @@ test_master (void *cls, 100, &barrier_cb, NULL); - shutdown_task = + timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10 * (NUM_PEERS + 1)), - &do_shutdown, NULL); + &do_timeout, NULL); + GNUNET_SCHEDULER_add_shutdown(&shutdown_handler, NULL); } -- 2.25.1