From: Sree Harsha Totakura Date: Thu, 27 Oct 2016 15:01:52 +0000 (+0000) Subject: propagate barrier status messages to sub controllers X-Git-Tag: initial-import-from-subversion-38251~23 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a85d0779cb1dad2c5d2aecff2d5be96f1e11b665;p=oweals%2Fgnunet.git propagate barrier status messages to sub controllers --- diff --git a/src/testbed/gnunet-service-testbed_barriers.c b/src/testbed/gnunet-service-testbed_barriers.c index 638263103..a201d22bb 100644 --- a/src/testbed/gnunet-service-testbed_barriers.c +++ b/src/testbed/gnunet-service-testbed_barriers.c @@ -108,6 +108,11 @@ struct WBarrier */ struct Barrier *barrier; + /** + * Handle to the slave controller where this wrapper creates a barrier + */ + struct GNUNET_TESTBED_Controller *controller; + /** * The barrier handle from API */ @@ -546,14 +551,7 @@ 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, - barrier->wtail, - wrapper); - GNUNET_free (wrapper); switch (status) { case GNUNET_TESTBED_BARRIERSTATUS_ERROR: @@ -712,11 +710,12 @@ handle_barrier_init (void *cls, } wrapper = GNUNET_new (struct WBarrier); wrapper->barrier = barrier; + wrapper->controller = slave->controller; GNUNET_CONTAINER_DLL_insert_tail (barrier->whead, barrier->wtail, wrapper); - //FIXME: Increment barrier->num_wbarriers - wrapper->hbarrier = GNUNET_TESTBED_barrier_init_ (slave->controller, + barrier->num_wbarriers++; + wrapper->hbarrier = GNUNET_TESTBED_barrier_init_ (wrapper->controller, barrier->name, barrier->quorum, &wbarrier_status_cb, @@ -868,6 +867,7 @@ handle_barrier_status (void *cls, struct GNUNET_SERVICE_Client *client = cls; struct Barrier *barrier; struct ClientCtx *client_ctx; + struct WBarrier *wrapper; const char *name; struct GNUNET_HashCode key; uint16_t name_len; @@ -907,7 +907,15 @@ handle_barrier_status (void *cls, GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client_ctx->client), env); } - //FIXME: Send status to wrappers if they exist + /** + * The wrapper barriers do not echo the barrier status, so we have to do it + * here + */ + for (wrapper = barrier->whead; NULL != wrapper; wrapper = wrapper->next) + { + GNUNET_TESTBED_queue_message_ (wrapper->controller, + GNUNET_copy_message (&msg->header)); + } } /* end of gnunet-service-testbed_barriers.c */ diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index a019d9b64..ae40948b3 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c @@ -1310,7 +1310,13 @@ handle_barrier_status (void *cls, cleanup: GNUNET_free_non_null (emsg); - if (NULL != barrier) + /** + * Do not remove the barrier if we did not echo the status back; this is + * required at the chained testbed controller setup to ensure the only the + * test-driver echos the status and the controller hierarchy properly + * propagates the status. + */ + if ((NULL != barrier) && (GNUNET_YES == barrier->echo)) GNUNET_TESTBED_barrier_remove_ (barrier); }