Suppress duplicate dns_db_updatenotify_register registrations

Duplicate dns_db_updatenotify_register registrations need to be
suppressed to ensure that dns_db_updatenotify_unregister is successful.

(cherry picked from commit f13e71e551)
This commit is contained in:
Mark Andrews 2022-11-30 18:40:27 +11:00
parent b2a4447af8
commit ffeda92cd8
3 changed files with 15 additions and 5 deletions

View 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);

View 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;

View 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
*
*/