]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
rearrange nm_teardown() to check correctness after shutting down
authorEvan Hunt <each@isc.org>
Sat, 3 Apr 2021 05:34:18 +0000 (22:34 -0700)
committerOndřej Surý <ondrej@sury.org>
Wed, 7 Apr 2021 13:36:59 +0000 (15:36 +0200)
if a test failed at the beginning of nm_teardown(), the function
would abort before isc_nm_destroy() or isc_tlsctx_free() were reached;
we would then abort when nm_setup() was run for the next test case.
rearranging the teardown function prevents this problem.

lib/isc/tests/netmgr_test.c

index 631001e408924da93a34b474756c44bfa1692ffe..04362a361a782e24b2269da3ef2e5d1a843c70e9 100644 (file)
@@ -330,27 +330,27 @@ static int
 nm_teardown(void **state __attribute__((unused))) {
        UNUSED(state);
 
-       WAIT_FOR_EQ(active_cconnects, 0);
-       WAIT_FOR_EQ(active_csends, 0);
-       WAIT_FOR_EQ(active_csends, 0);
-       WAIT_FOR_EQ(active_ssends, 0);
-       WAIT_FOR_EQ(active_sreads, 0);
-
        isc_nm_destroy(&connect_nm);
        assert_null(connect_nm);
 
        isc_nm_destroy(&listen_nm);
        assert_null(listen_nm);
 
+       isc_tlsctx_free(&tcp_connect_tlsctx);
+       isc_tlsctx_free(&tcp_listen_tlsctx);
+
+       WAIT_FOR_EQ(active_cconnects, 0);
+       WAIT_FOR_EQ(active_csends, 0);
+       WAIT_FOR_EQ(active_csends, 0);
+       WAIT_FOR_EQ(active_ssends, 0);
+       WAIT_FOR_EQ(active_sreads, 0);
+
        isc_refcount_destroy(&active_cconnects);
        isc_refcount_destroy(&active_csends);
        isc_refcount_destroy(&active_creads);
        isc_refcount_destroy(&active_ssends);
        isc_refcount_destroy(&active_sreads);
 
-       isc_tlsctx_free(&tcp_connect_tlsctx);
-       isc_tlsctx_free(&tcp_listen_tlsctx);
-
        return (0);
 }