]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
catzs->view should maintain a view reference
authorMark Andrews <marka@isc.org>
Tue, 30 Apr 2024 01:04:31 +0000 (11:04 +1000)
committerMark Andrews <marka@isc.org>
Thu, 9 May 2024 00:22:00 +0000 (10:22 +1000)
Use dns_view_weakattach and dns_view_weakdetach to maintain a
reference to the view referenced through catzs->view.

(cherry picked from commit 307e3ed9a66a2a90f38c59f7854529ffb76d93f8)

lib/dns/catz.c

index a8727014ca4323e25a73d735a67fe9db59d58f85..616d598e307587333852ff192c944eab2f38383a 100644 (file)
@@ -818,7 +818,12 @@ dns_catz_catzs_set_view(dns_catz_zones_t *catzs, dns_view_t *view) {
        /* Either it's a new one or it's being reconfigured. */
        REQUIRE(catzs->view == NULL || !strcmp(catzs->view->name, view->name));
 
-       catzs->view = view;
+       if (catzs->view == NULL) {
+               dns_view_weakattach(view, &catzs->view);
+       } else if (catzs->view != view) {
+               dns_view_weakdetach(&catzs->view);
+               dns_view_weakattach(view, &catzs->view);
+       }
 }
 
 isc_result_t
@@ -1034,6 +1039,9 @@ dns__catz_zones_destroy(dns_catz_zones_t *catzs) {
        isc_task_detach(&catzs->updater);
        isc_mutex_destroy(&catzs->lock);
        isc_refcount_destroy(&catzs->references);
+       if (catzs->view != NULL) {
+               dns_view_weakdetach(&catzs->view);
+       }
 
        isc_mem_putanddetach(&catzs->mctx, catzs, sizeof(*catzs));
 }