unsigned int magic;
isc_mutex_t lock;
isc_mem_t *mctx; /* Memory context for the dns_cache object */
- isc_mem_t *hmctx; /* Heap memory */
isc_mem_t *tmctx; /* Tree memory */
char *name;
isc_refcount_t references;
***/
static isc_result_t
-cache_create_db(dns_cache_t *cache, dns_db_t **dbp, isc_mem_t **tmctxp,
- isc_mem_t **hmctxp) {
+cache_create_db(dns_cache_t *cache, dns_db_t **dbp, isc_mem_t **tmctxp) {
isc_result_t result;
- char *argv[1] = { 0 };
dns_db_t *db = NULL;
- isc_mem_t *tmctx = NULL, *hmctx = NULL;
+ isc_mem_t *tmctx = NULL;
/*
* This will be the cache memory context, which is subject
*/
isc_mem_create("cache", &tmctx);
- /*
- * This will be passed to RBTDB to use for heaps. This is separate
- * from the main cache memory because it can grow quite large under
- * heavy load and could otherwise cause the cache to be cleaned too
- * aggressively.
- */
- isc_mem_create("cache_heap", &hmctx);
-
- /*
- * For databases of type "qpcache" or "rbt" (which are the
- * only cache implementations currently in existence) we pass
- * hmctx to dns_db_create() via argv[0].
- */
- argv[0] = (char *)hmctx;
result = dns_db_create(tmctx, CACHEDB_DEFAULT, dns_rootname,
- dns_dbtype_cache, cache->rdclass, 1, argv, &db);
+ dns_dbtype_cache, cache->rdclass, 0, NULL, &db);
if (result != ISC_R_SUCCESS) {
goto cleanup_mctx;
}
dns_db_setmaxtypepername(db, cache->maxtypepername);
*dbp = db;
- *hmctxp = hmctx;
*tmctxp = tmctx;
return ISC_R_SUCCESS;
cleanup_db:
dns_db_detach(&db);
cleanup_mctx:
- isc_mem_detach(&hmctx);
isc_mem_detach(&tmctx);
return result;
isc_stats_detach(&cache->stats);
isc_mutex_destroy(&cache->lock);
isc_mem_free(cache->mctx, cache->name);
- if (cache->hmctx != NULL) {
- isc_mem_detach(&cache->hmctx);
- }
if (cache->tmctx != NULL) {
isc_mem_detach(&cache->tmctx);
}
/*
* Create the database
*/
- CHECK(cache_create_db(cache, &cache->db, &cache->tmctx, &cache->hmctx));
+ CHECK(cache_create_db(cache, &cache->db, &cache->tmctx));
*cachep = cache;
return ISC_R_SUCCESS;
dns_cache_flush(dns_cache_t *cache) {
dns_db_t *db = NULL, *olddb = NULL;
isc_mem_t *tmctx = NULL, *oldtmctx = NULL;
- isc_mem_t *hmctx = NULL, *oldhmctx = NULL;
- RETERR(cache_create_db(cache, &db, &tmctx, &hmctx));
+ RETERR(cache_create_db(cache, &db, &tmctx));
LOCK(&cache->lock);
isc_mem_clearwater(cache->tmctx);
- oldhmctx = cache->hmctx;
- cache->hmctx = hmctx;
oldtmctx = cache->tmctx;
cache->tmctx = tmctx;
updatewater(cache);
UNLOCK(&cache->lock);
dns_db_detach(&olddb);
- isc_mem_detach(&oldhmctx);
isc_mem_detach(&oldtmctx);
return ISC_R_SUCCESS;
fprintf(fp, "%20" PRIu64 " %s\n", (uint64_t)isc_mem_inuse(cache->tmctx),
"cache tree memory in use");
-
- fprintf(fp, "%20" PRIu64 " %s\n", (uint64_t)isc_mem_inuse(cache->hmctx),
- "cache heap memory in use");
}
#ifdef HAVE_LIBXML2
TRY0(renderstat("CacheNodes", dns_db_nodecount(cache->db), writer));
TRY0(renderstat("TreeMemInUse", isc_mem_inuse(cache->tmctx), writer));
-
- TRY0(renderstat("HeapMemInUse", isc_mem_inuse(cache->hmctx), writer));
error:
return xmlrc;
}
CHECKMEM(obj);
json_object_object_add(cstats, "TreeMemInUse", obj);
- obj = json_object_new_int64(isc_mem_inuse(cache->hmctx));
- CHECKMEM(obj);
- json_object_object_add(cstats, "HeapMemInUse", obj);
-
result = ISC_R_SUCCESS;
error:
return result;
/* Locked by tree_lock. */
dns_qp_t *tree;
- isc_mem_t *hmctx; /* Memory context for the heaps */
-
size_t buckets_count;
qpcache_bucket_t buckets[]; /* attribute((counted_by(buckets_count))) */
};
isc_rwlock_destroy(&qpdb->lock);
qpdb->common.magic = 0;
qpdb->common.impmagic = 0;
- isc_mem_detach(&qpdb->hmctx);
isc_mem_putanddetach(&qpdb->common.mctx, qpdb,
sizeof(*qpdb) + qpdb->buckets_count *
unsigned int argc, char *argv[],
void *driverarg ISC_ATTR_UNUSED, dns_db_t **dbp) {
qpcache_t *qpdb = NULL;
- isc_mem_t *hmctx = mctx;
isc_loop_t *loop = isc_loop();
int i;
size_t nloops = isc_loopmgr_nloops();
/* This database implementation only supports cache semantics */
REQUIRE(type == dns_dbtype_cache);
REQUIRE(loop != NULL);
+ REQUIRE(argc == 0);
+ REQUIRE(argv == NULL);
qpdb = isc_mem_get(mctx,
sizeof(*qpdb) + nloops * sizeof(qpdb->buckets[0]));
.buckets_count = nloops,
};
- /*
- * If argv[0] exists, it points to a memory context to use for heap
- */
- if (argc != 0) {
- hmctx = (isc_mem_t *)argv[0];
- }
-
isc_rwlock_init(&qpdb->lock);
TREE_INITLOCK(&qpdb->tree_lock);
* mctx won't disappear out from under us.
*/
isc_mem_attach(mctx, &qpdb->common.mctx);
- isc_mem_attach(hmctx, &qpdb->hmctx);
/*
* Make a copy of the origin name.