mirror of
https://github.com/isc-projects/bind9.git
synced 2026-02-24 10:21:10 -05:00
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:
parent
b2a4447af8
commit
ffeda92cd8
3 changed files with 15 additions and 5 deletions
|
|
@ -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);
|
||||
|
|
|
|||
12
lib/dns/db.c
12
lib/dns/db.c
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue