From ca48cdf0acefe41a5ea1712670566a0e07571710 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 14 Jun 2012 15:15:57 +1000 Subject: [PATCH] 3338. [bug] Address race condition in units tests: asyncload_zone and asyncload_zt. [RT #26100] --- CHANGES | 3 +++ lib/dns/tests/zt_test.c | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 79e8c530ba..0a33ae88a8 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3338. [bug] Address race condition in units tests: asyncload_zone + and asyncload_zt. [RT #26100] + 3337. [bug] Change #3294 broke support for the multiple keys in controls. [RT #29694] diff --git a/lib/dns/tests/zt_test.c b/lib/dns/tests/zt_test.c index 80d11cd630..176d477903 100644 --- a/lib/dns/tests/zt_test.c +++ b/lib/dns/tests/zt_test.c @@ -37,6 +37,11 @@ #include "dnstest.h" +struct args { + void *arg1; + void *arg2; +}; + /* * Helper functions */ @@ -72,6 +77,27 @@ all_done(void *arg) { return (ISC_R_SUCCESS); } +static void +start_zt_asyncload(isc_task_t *task, isc_event_t *event) { + struct args *args = (struct args *)(event->ev_arg); + + UNUSED(task); + + dns_zt_asyncload(args->arg1, all_done, args->arg2); + + isc_event_free(&event); +} + +static void +start_zone_asyncload(isc_task_t *task, isc_event_t *event) { + struct args *args = (struct args *)(event->ev_arg); + + UNUSED(task); + + dns_zone_asyncload(args->arg1, load_done, args->arg2); + isc_event_free(&event); +} + /* * Individual unit tests */ @@ -127,6 +153,7 @@ ATF_TC_BODY(asyncload_zone, tc) { dns_db_t *db = NULL; isc_boolean_t done = ISC_FALSE; int i = 0; + struct args args; UNUSED(tc); @@ -147,8 +174,10 @@ ATF_TC_BODY(asyncload_zone, tc) { ATF_CHECK(!dns__zone_loadpending(zone)); ATF_CHECK(!done); dns_zone_setfile(zone, "testdata/zt/zone1.db"); - dns_zone_asyncload(zone, load_done, (void *) &done); - ATF_CHECK(dns__zone_loadpending(zone)); + + args.arg1 = zone; + args.arg2 = &done; + isc_app_onrun(mctx, maintask, start_zone_asyncload, &args); isc_app_run(); while (dns__zone_loadpending(zone) && i++ < 5000) @@ -183,6 +212,7 @@ ATF_TC_BODY(asyncload_zt, tc) { dns_db_t *db = NULL; isc_boolean_t done = ISC_FALSE; int i = 0; + struct args args; UNUSED(tc); @@ -218,7 +248,10 @@ ATF_TC_BODY(asyncload_zt, tc) { ATF_CHECK(!dns__zone_loadpending(zone1)); ATF_CHECK(!dns__zone_loadpending(zone2)); ATF_CHECK(!done); - dns_zt_asyncload(zt, all_done, (void *) &done); + + args.arg1 = zt; + args.arg2 = &done; + isc_app_onrun(mctx, maintask, start_zt_asyncload, &args); isc_app_run(); while (!done && i++ < 5000)