From ad45e5ab7a679e493d6c28910b2d01b73e0d7e57 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 2 May 2016 06:48:25 +0200 Subject: adjust shutdown/timeout to match latest GNUnet scheduler API semantics --- src/bank-lib/test_bank_api.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/bank-lib/test_bank_api.c b/src/bank-lib/test_bank_api.c index 019b09976..b92cf5a55 100644 --- a/src/bank-lib/test_bank_api.c +++ b/src/bank-lib/test_bank_api.c @@ -33,9 +33,9 @@ static struct GNUNET_CURL_Context *ctx; /** - * Task run on shutdown. + * Task run on timeout. */ -static struct GNUNET_SCHEDULER_Task *shutdown_task; +static struct GNUNET_SCHEDULER_Task *timeout_task; /** * Task that runs the main event loop. @@ -348,6 +348,19 @@ interpreter_run (void *cls) } +/** + * Function run on timeout. + * + * @param cls NULL + */ +static void +do_timeout (void *cls) +{ + timeout_task = NULL; + GNUNET_SCHEDULER_shutdown (); +} + + /** * Function run when the test terminates (good or bad). * Cleans up our state. @@ -361,7 +374,12 @@ do_shutdown (void *cls) struct Command *cmd; unsigned int i; - shutdown_task = NULL; + if (NULL != timeout_task) + { + GNUNET_SCHEDULER_cancel (timeout_task); + timeout_task = NULL; + } + for (i=0;OC_END != (cmd = &is->commands[i])->oc;i++) { switch (cmd->oc) @@ -494,10 +512,11 @@ run (void *cls) ctx); is->task = GNUNET_SCHEDULER_add_now (&interpreter_run, is); - shutdown_task + timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 150), - &do_shutdown, is); + &do_timeout, is); + GNUNET_SCHEDULER_add_shutdown (&do_shutdown, is); } -- cgit v1.2.3