mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 05:57:52 +00:00
Support ondestroy notfication of databases.
This commit is contained in:
parent
e32ccd2b77
commit
d549c37348
10
lib/dns/db.c
10
lib/dns/db.c
@ -25,6 +25,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/ondestroy.h>
|
||||
|
||||
#include <dns/db.h>
|
||||
#include <dns/master.h>
|
||||
@ -118,6 +119,15 @@ dns_db_detach(dns_db_t **dbp) {
|
||||
ENSURE(*dbp == NULL);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_db_ondestroy(dns_db_t *db, isc_task_t *task, isc_event_t **eventp)
|
||||
{
|
||||
REQUIRE(DNS_DB_VALID(db));
|
||||
|
||||
return (isc_ondestroy_register(&db->ondest, task, eventp));
|
||||
}
|
||||
|
||||
|
||||
isc_boolean_t
|
||||
dns_db_iscache(dns_db_t *db) {
|
||||
|
||||
|
@ -164,6 +164,7 @@ struct dns_db {
|
||||
isc_uint16_t attributes;
|
||||
dns_rdataclass_t rdclass;
|
||||
dns_name_t origin;
|
||||
isc_ondestroy_t ondest;
|
||||
isc_mem_t * mctx;
|
||||
};
|
||||
|
||||
@ -267,6 +268,17 @@ dns_db_detach(dns_db_t **dbp);
|
||||
* All resources used by the database will be freed
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
dns_db_ondestroy(dns_db_t *db, isc_task_t *task, isc_event_t **eventp);
|
||||
/*
|
||||
* Causes 'eventp' to be sent to be sent to 'task' when the database is
|
||||
* destroyed.
|
||||
*
|
||||
* Note; ownrship of the eventp is taken from the caller (and *eventp is
|
||||
* set to NULL). The sender field of the event is set to 'db' before it is
|
||||
* sent to the task.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
dns_db_iscache(dns_db_t *db);
|
||||
/*
|
||||
|
@ -45,6 +45,7 @@ ISC_LANG_BEGINDECLS
|
||||
#define DNS_EVENT_CACHECLEAN (ISC_EVENTCLASS_DNS + 15)
|
||||
#define DNS_EVENT_BYADDRDONE (ISC_EVENTCLASS_DNS + 16)
|
||||
#define DNS_EVENT_ZONECONTROL (ISC_EVENTCLASS_DNS + 17)
|
||||
#define DNS_EVENT_DBDESTROYED (ISC_EVENTCLASS_DNS + 18)
|
||||
|
||||
#define DNS_EVENT_FIRSTEVENT (ISC_EVENTCLASS_DNS + 0)
|
||||
#define DNS_EVENT_LASTEVENT (ISC_EVENTCLASS_DNS + 65535)
|
||||
|
@ -313,6 +313,7 @@ static void
|
||||
free_rbtdb(dns_rbtdb_t *rbtdb) {
|
||||
unsigned int i;
|
||||
isc_region_t r;
|
||||
isc_ondestroy_t ondest;
|
||||
|
||||
REQUIRE(EMPTY(rbtdb->open_versions));
|
||||
REQUIRE(rbtdb->future_version == NULL);
|
||||
@ -332,7 +333,9 @@ free_rbtdb(dns_rbtdb_t *rbtdb) {
|
||||
isc_mutex_destroy(&rbtdb->lock);
|
||||
rbtdb->common.magic = 0;
|
||||
rbtdb->common.impmagic = 0;
|
||||
ondest = rbtdb->common.ondest;
|
||||
isc_mem_put(rbtdb->common.mctx, rbtdb, sizeof *rbtdb);
|
||||
isc_ondestroy_notify(&ondest, rbtdb);
|
||||
}
|
||||
|
||||
static inline void
|
||||
@ -3924,6 +3927,8 @@ dns_rbtdb_create
|
||||
rbtdb->future_version = NULL;
|
||||
ISC_LIST_INIT(rbtdb->open_versions);
|
||||
|
||||
isc_ondestroy_init(&rbtdb->common.ondest);
|
||||
|
||||
rbtdb->common.magic = DNS_DB_MAGIC;
|
||||
rbtdb->common.impmagic = RBTDB_MAGIC;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user