From 8919055de77f692ce3f0c1b9781fc9011de9cb6f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 21 Jun 2016 11:44:29 +0000 Subject: [PATCH] -fix testcase to manage with new shutdown semantics --- .../test_gnunet_daemon_hostlist_reconnect.c | 65 +++++++++---------- 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c index 562eec55b..3dad137a2 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c @@ -51,32 +51,6 @@ static struct PeerContext p1; static struct PeerContext p2; -static void -clean_up (void *cls) -{ - if (NULL != p1.ghh) - { - GNUNET_TRANSPORT_get_hello_cancel (p1.ghh); - p1.ghh = NULL; - } - if (p1.th != NULL) - { - GNUNET_TRANSPORT_disconnect (p1.th); - p1.th = NULL; - } - if (NULL != p2.ghh) - { - GNUNET_TRANSPORT_get_hello_cancel (p2.ghh); - p2.ghh = NULL; - } - if (p2.th != NULL) - { - GNUNET_TRANSPORT_disconnect (p2.th); - p2.th = NULL; - } - GNUNET_SCHEDULER_shutdown (); -} - /** * Timeout, give up. */ @@ -86,7 +60,7 @@ timeout_error (void *cls) timeout_task = NULL; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout trying to connect peers, test failed.\n"); - clean_up (NULL); + GNUNET_SCHEDULER_shutdown (); } @@ -108,12 +82,7 @@ notify_connect (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected, shutting down.\n"); ok = 0; - if (timeout_task != NULL) - { - GNUNET_SCHEDULER_cancel (timeout_task); - timeout_task = NULL; - } - GNUNET_SCHEDULER_add_now (&clean_up, NULL); + GNUNET_SCHEDULER_shutdown (); } @@ -185,6 +154,31 @@ stop_arm (struct PeerContext *p) static void shutdown_task (void *cls) { + if (NULL != timeout_task) + { + GNUNET_SCHEDULER_cancel (timeout_task); + timeout_task = NULL; + } + if (NULL != p1.ghh) + { + GNUNET_TRANSPORT_get_hello_cancel (p1.ghh); + p1.ghh = NULL; + } + if (p1.th != NULL) + { + GNUNET_TRANSPORT_disconnect (p1.th); + p1.th = NULL; + } + if (NULL != p2.ghh) + { + GNUNET_TRANSPORT_get_hello_cancel (p2.ghh); + p2.ghh = NULL; + } + if (p2.th != NULL) + { + GNUNET_TRANSPORT_disconnect (p2.th); + p2.th = NULL; + } stop_arm (&p1); stop_arm (&p2); } @@ -198,9 +192,8 @@ run (void *cls, char *const *args, const char *cfgfile, ok++; timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_error, NULL); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, - NULL); + GNUNET_SCHEDULER_add_shutdown (&shutdown_task, + NULL); setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf"); setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf"); } -- 2.25.1