]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Suppress duplicate dns_db_updatenotify_register registrations
authorMark Andrews <marka@isc.org>
Wed, 30 Nov 2022 07:40:27 +0000 (18:40 +1100)
committerMark Andrews <marka@isc.org>
Tue, 6 Dec 2022 22:46:50 +0000 (09:46 +1100)
Duplicate dns_db_updatenotify_register registrations need to be
suppressed to ensure that dns_db_updatenotify_unregister is successful.

(cherry picked from commit f13e71e55167bf9c94f4faf1dab110467158e7b4)

lib/dns/catz.c
lib/dns/db.c
lib/dns/include/dns/db.h

index 487d20833e16c94fe821b345d1ded7d9790ddec4..332f9877360bbe8ca112fbf4f9973962267bf104 100644 (file)
@@ -810,9 +810,9 @@ dns_catz_zone_detach(dns_catz_zone_t **zonep) {
                zone->magic = 0;
                isc_timer_detach(&zone->updatetimer);
                if (zone->db_registered) {
-                       INSIST(dns_db_updatenotify_unregister(
-                                      zone->db, dns_catz_dbupdate_callback,
-                                      zone->catzs) == ISC_R_SUCCESS);
+                       dns_db_updatenotify_unregister(
+                               zone->db, dns_catz_dbupdate_callback,
+                               zone->catzs);
                }
                if (zone->dbversion) {
                        dns_db_closeversion(zone->db, &zone->dbversion, false);
index c5de3d9e0b0a0f782982e844645b608a41ad4cf5..04cf6560feaec9b41646530e2f212f6cd925759e 100644 (file)
@@ -1013,7 +1013,7 @@ dns_db_rpz_ready(dns_db_t *db) {
        return ((db->methods->rpz_ready)(db));
 }
 
-/**
+/*
  * Attach a notify-on-update function the database
  */
 isc_result_t
@@ -1024,6 +1024,16 @@ dns_db_updatenotify_register(dns_db_t *db, dns_dbupdate_callback_t fn,
        REQUIRE(db != NULL);
        REQUIRE(fn != NULL);
 
+       for (listener = ISC_LIST_HEAD(db->update_listeners); listener != NULL;
+            listener = ISC_LIST_NEXT(listener, link))
+       {
+               if ((listener->onupdate == fn) &&
+                   (listener->onupdate_arg == fn_arg))
+               {
+                       return (ISC_R_SUCCESS);
+               }
+       }
+
        listener = isc_mem_get(db->mctx, sizeof(dns_dbonupdatelistener_t));
 
        listener->onupdate = fn;
index f14d9f6c5294d7fe8648aa8609b63f7f433e11f5..08bdc80e4ee3a41c0519ee50e78b0ebe403a2bc7 100644 (file)
@@ -1673,11 +1673,11 @@ dns_db_updatenotify_register(dns_db_t *db, dns_dbupdate_callback_t fn,
                             void *fn_arg);
 /*%<
  * Register a notify-on-update callback function to a database.
+ * Duplicate callbacks are suppressed.
  *
  * Requires:
  *
  * \li 'db' is a valid database
- * \li 'db' does not have an update callback registered
  * \li 'fn' is not NULL
  *
  */