mirror of
https://github.com/isc-projects/bind9.git
synced 2026-07-16 15:12:51 -04:00
Free the slabheader proofs in its destructor
Now that the slabheader carries its own memory context, free its noqname/closest proofs from slabheader_destroy rather than reaching through the owning node's deletedata method. That was the method's last caller, so remove dns_db_deletedata entirely; the cache bookkeeping it performed (rrset statistics and the dirty list) becomes a plain helper called wherever a header leaves the cache.
This commit is contained in:
parent
d9701e1fae
commit
202889b044
4 changed files with 18 additions and 35 deletions
|
|
@ -1070,14 +1070,6 @@ dns_db_expiredata(dns_dbnode_t *node, void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
dns_db_deletedata(dns_dbnode_t *node, void *data) {
|
||||
REQUIRE(node != NULL && node->methods != NULL);
|
||||
if (node->methods->deletedata != NULL) {
|
||||
(node->methods->deletedata)(node, data);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
dns_db_setmaxrrperset(dns_db_t *db, uint32_t value) {
|
||||
REQUIRE(DNS_DB_VALID(db));
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ typedef struct dns_dbnode_methods {
|
|||
dns_dbnode_t **targetp DNS__DB_FLARG);
|
||||
void (*detachnode)(dns_dbnode_t **targetp DNS__DB_FLARG);
|
||||
|
||||
void (*deletedata)(dns_dbnode_t *node, void *data);
|
||||
void (*expiredata)(dns_dbnode_t *node, void *data);
|
||||
} dns_dbnode_methods_t;
|
||||
|
||||
|
|
@ -1772,14 +1771,6 @@ dns_db_expiredata(dns_dbnode_t *node, void *data);
|
|||
* node 'node' as expired.
|
||||
*/
|
||||
|
||||
void
|
||||
dns_db_deletedata(dns_dbnode_t *node, void *data);
|
||||
/*%<
|
||||
* Tell the database to prepare to delete the block of data 'data'
|
||||
* stored at node 'node. This may include, for example, removing the
|
||||
* data from an LRU list or a heap.
|
||||
*/
|
||||
|
||||
void
|
||||
dns_db_setmaxrrperset(dns_db_t *db, uint32_t value);
|
||||
/*%<
|
||||
|
|
|
|||
|
|
@ -265,14 +265,11 @@ qpcnode_attachnode(dns_dbnode_t *source, dns_dbnode_t **targetp DNS__DB_FLARG);
|
|||
static void
|
||||
qpcnode_detachnode(dns_dbnode_t **nodep DNS__DB_FLARG);
|
||||
static void
|
||||
qpcnode_deletedata(dns_dbnode_t *node, void *data);
|
||||
static void
|
||||
qpcnode_expiredata(dns_dbnode_t *node, void *data);
|
||||
|
||||
static dns_dbnode_methods_t qpcnode_methods = (dns_dbnode_methods_t){
|
||||
.attachnode = qpcnode_attachnode,
|
||||
.detachnode = qpcnode_detachnode,
|
||||
.deletedata = qpcnode_deletedata,
|
||||
.expiredata = qpcnode_expiredata,
|
||||
};
|
||||
|
||||
|
|
@ -527,6 +524,9 @@ qpcache_hit(qpcache_t *qpdb ISC_ATTR_UNUSED, dns_slabheader_t *header) {
|
|||
* DB Routines
|
||||
*/
|
||||
|
||||
static void
|
||||
header_cleanup(dns_dbnode_t *node ISC_ATTR_UNUSED, void *data);
|
||||
|
||||
static void
|
||||
clean_cache_headers(dns_slabtop_t *top) {
|
||||
dns_slabheader_t *parent = first_header(top);
|
||||
|
|
@ -537,7 +537,7 @@ clean_cache_headers(dns_slabtop_t *top) {
|
|||
dns_slabheader_t *header = next_header(parent), *header_next = NULL;
|
||||
cds_list_for_each_entry_safe_from(header, header_next, &top->headers,
|
||||
headers_link) {
|
||||
cds_list_del(&header->headers_link);
|
||||
header_cleanup(header->node, header);
|
||||
dns_slabheader_detach(&header);
|
||||
}
|
||||
}
|
||||
|
|
@ -573,7 +573,7 @@ clean_cache_node(qpcache_t *qpdb, qpcnode_t *node) {
|
|||
if (!EXISTS(header) || ANCIENT(header) ||
|
||||
(STALE(header) && !KEEPSTALE(qpdb)))
|
||||
{
|
||||
cds_list_del(&header->headers_link);
|
||||
header_cleanup(header->node, header);
|
||||
dns_slabheader_detach(&header);
|
||||
}
|
||||
|
||||
|
|
@ -2819,11 +2819,11 @@ qpcache_addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
|||
DNS_SLABHEADER_SETATTR(newheader, DNS_SLABHEADERATTR_OPTOUT);
|
||||
}
|
||||
if (rdataset->attributes.noqname) {
|
||||
CHECK(addnoqname(qpnode->mctx, newheader, qpdb->maxrrperset,
|
||||
CHECK(addnoqname(newheader->mctx, newheader, qpdb->maxrrperset,
|
||||
rdataset));
|
||||
}
|
||||
if (rdataset->attributes.closest) {
|
||||
CHECK(addclosest(qpnode->mctx, newheader, qpdb->maxrrperset,
|
||||
CHECK(addclosest(newheader->mctx, newheader, qpdb->maxrrperset,
|
||||
rdataset));
|
||||
}
|
||||
|
||||
|
|
@ -3453,10 +3453,12 @@ dbiterator_origin(dns_dbiterator_t *iterator, dns_name_t *name) {
|
|||
}
|
||||
|
||||
static void
|
||||
qpcnode_deletedata(dns_dbnode_t *node ISC_ATTR_UNUSED, void *data) {
|
||||
header_cleanup(dns_dbnode_t *node ISC_ATTR_UNUSED, void *data) {
|
||||
dns_slabheader_t *header = data;
|
||||
qpcache_t *qpdb = HEADERNODE(header)->qpdb;
|
||||
|
||||
cds_list_del(&header->headers_link);
|
||||
|
||||
if (ISC_LINK_LINKED(header, dirtylink)) {
|
||||
ISC_LIST_UNLINK(HEADERNODE(header)->dirty, header, dirtylink);
|
||||
}
|
||||
|
|
@ -3466,13 +3468,6 @@ qpcnode_deletedata(dns_dbnode_t *node ISC_ATTR_UNUSED, void *data) {
|
|||
*/
|
||||
update_rrsetstats(qpdb->rrsetstats, header->typepair,
|
||||
atomic_load_acquire(&header->attributes), false);
|
||||
|
||||
if (header->noqname != NULL) {
|
||||
dns_slabheader_freeproof(qpdb->common.mctx, &header->noqname);
|
||||
}
|
||||
if (header->closest != NULL) {
|
||||
dns_slabheader_freeproof(qpdb->common.mctx, &header->closest);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -3522,7 +3517,7 @@ qpcnode_destroy(qpcnode_t *qpnode) {
|
|||
cds_list_for_each_entry_safe(header, header_next, &top->headers,
|
||||
headers_link)
|
||||
{
|
||||
cds_list_del(&header->headers_link);
|
||||
header_cleanup(header->node, header);
|
||||
dns_slabheader_detach(&header);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -572,14 +572,19 @@ static void
|
|||
slabheader_destroy(dns_slabheader_t *header) {
|
||||
unsigned int size;
|
||||
|
||||
dns_db_deletedata(header->node, header);
|
||||
|
||||
if (EXISTS(header)) {
|
||||
size = dns_rdataslab_size(header);
|
||||
} else {
|
||||
size = sizeof(*header);
|
||||
}
|
||||
|
||||
if (header->noqname != NULL) {
|
||||
dns_slabheader_freeproof(header->mctx, &header->noqname);
|
||||
}
|
||||
if (header->closest != NULL) {
|
||||
dns_slabheader_freeproof(header->mctx, &header->closest);
|
||||
}
|
||||
|
||||
isc_mem_putanddetach(&header->mctx, header, size);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue