From f5578375b94757504d58994e4af829250d1330e6 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 2 Jul 2016 20:00:00 +0000 Subject: -fix testcase shutdown --- src/pt/test_gns_vpn.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'src/pt/test_gns_vpn.c') diff --git a/src/pt/test_gns_vpn.c b/src/pt/test_gns_vpn.c index 7e5bb503d..467a15310 100644 --- a/src/pt/test_gns_vpn.c +++ b/src/pt/test_gns_vpn.c @@ -54,6 +54,8 @@ static struct GNUNET_SCHEDULER_Task *mhd_task_id; static struct GNUNET_SCHEDULER_Task *curl_task_id; +static struct GNUNET_SCHEDULER_Task *timeout_task; + static struct GNUNET_IDENTITY_Handle *identity; static struct GNUNET_NAMESTORE_QueueEntry *qe; @@ -142,16 +144,21 @@ mhd_ahc (void *cls, static void do_shutdown (void *cls) { - if (mhd_task_id != NULL) + if (NULL != mhd_task_id) { GNUNET_SCHEDULER_cancel (mhd_task_id); mhd_task_id = NULL; } - if (curl_task_id != NULL) + if (NULL != curl_task_id) { GNUNET_SCHEDULER_cancel (curl_task_id); curl_task_id = NULL; } + if (NULL != timeout_task) + { + GNUNET_SCHEDULER_cancel (timeout_task); + timeout_task = NULL; + } if (NULL != mhd) { MHD_stop_daemon (mhd); @@ -172,6 +179,14 @@ do_shutdown (void *cls) } +static void +do_timeout (void *cls) +{ + timeout_task = NULL; + GNUNET_SCHEDULER_shutdown (); +} + + /** * Function to run the HTTP client. */ @@ -236,7 +251,8 @@ curl_main () GNUNET_break (0); global_ret = 3; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download complete, shutting down!\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Download complete, shutting down!\n"); GNUNET_SCHEDULER_shutdown (); return; } @@ -622,9 +638,11 @@ run (void *cls, NULL }; GNUNET_TESTING_peer_get_identity (peer, &id); - GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &do_shutdown, - NULL); + GNUNET_SCHEDULER_add_shutdown (&do_shutdown, + NULL); + timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, + &do_timeout, + NULL); bin = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_BINDIR); GNUNET_asprintf (&bin_identity, "%s/%s", -- cgit v1.2.3