]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Destroy task first when destroying rpzs.
authorWitold Kręcicki <wpk@isc.org>
Tue, 30 Oct 2018 07:09:58 +0000 (07:09 +0000)
committerOndřej Surý <ondrej@sury.org>
Tue, 30 Oct 2018 13:01:01 +0000 (14:01 +0100)
When freeing rpzs structures we need to kill the updater task first.
Otherwise we might race with the updater and there might be a crash
on shutdown.

lib/dns/rpz.c

index 38fd3bd2cdf9f3abdfeeb81bab35f6707965736b..00751923e2b0fce3716b06e90c619c17cb10c827 100644 (file)
@@ -2148,7 +2148,12 @@ dns_rpz_detach_rpzs(dns_rpz_zones_t **rpzsp) {
        *rpzsp = NULL;
 
        if (isc_refcount_decrement(&rpzs->refs) == 1) {
-               isc_refcount_destroy(&rpzs->refs);
+               /*
+                * Destroy the task first, so that nothing runs
+                * in the background that might race with us.
+                */
+               isc_task_destroy(&rpzs->updater);
+
                /*
                 * Forget the last of view's rpz machinery after
                 * the last reference.
@@ -2178,7 +2183,7 @@ dns_rpz_detach_rpzs(dns_rpz_zones_t **rpzsp) {
                }
                DESTROYLOCK(&rpzs->maint_lock);
                isc_rwlock_destroy(&rpzs->search_lock);
-               isc_task_destroy(&rpzs->updater);
+               isc_refcount_destroy(&rpzs->refs);
                isc_mem_putanddetach(&rpzs->mctx, rpzs, sizeof(*rpzs));
        }
 }