From: Julius Bünger Date: Sun, 7 Jan 2018 21:07:31 +0000 (+0100) Subject: rps tests: proper shutdown X-Git-Tag: gnunet-0.11.0rc0~2^2~4 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c82abbd7168ca7db1ea2ef7c79f71e8a25fa32ce;p=oweals%2Fgnunet.git rps tests: proper shutdown --- diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index 992b4dc54..0268ff438 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c @@ -261,6 +261,11 @@ static unsigned int num_peers_online; */ static int ok; +/** + * Identifier for the churn task that runs periodically + */ +static struct GNUNET_SCHEDULER_Task *shutdown_task; + /** * Identifier for the churn task that runs periodically */ @@ -782,7 +787,10 @@ default_reply_handle (void *cls, if (0 == evaluate ()) { - GNUNET_SCHEDULER_shutdown (); + GNUNET_assert (NULL != shutdown_task); + GNUNET_SCHEDULER_cancel (shutdown_task); + shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL); + GNUNET_assert (NULL!= shutdown_task); } } @@ -1289,6 +1297,8 @@ churn (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Churn function executing\n"); + churn_task = NULL; /* Should be invalid by now */ + /* Compute the probability for an online peer to go offline * this round */ portion_online = num_peers_online * 1.0 / num_peers; @@ -1560,7 +1570,7 @@ run (void *cls, if (NULL != churn_task) GNUNET_SCHEDULER_cancel (churn_task); - GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); + shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); }