* view but is not yet configured. If it is not the
* view name but not a forward reference either, then it
* is simply a named cache that is not shared.
- *
- * We use two separate memory contexts for the
- * cache, for the main cache memory and the heap
- * memory.
*/
- isc_mem_create(&cmctx);
- isc_mem_setname(cmctx, "cache");
- CHECK(dns_cache_create(cmctx, named_g_taskmgr,
+ CHECK(dns_cache_create(mctx, named_g_taskmgr,
named_g_timermgr, view->rdclass,
cachename, "rbt", 0, NULL,
&cache));
- isc_mem_detach(&cmctx);
}
nsc = isc_mem_get(mctx, sizeof(*nsc));
nsc->cache = NULL;
/* Unlocked. */
unsigned int magic;
isc_mutex_t lock;
- isc_mem_t *mctx; /* Main cache memory */
+ isc_mem_t *mctx; /* Memory context for the dns_cache object */
isc_mem_t *hmctx; /* Heap memory */
isc_mem_t *tmctx; /* Tree memory */
isc_taskmgr_t *taskmgr;
}
isc_result_t
-dns_cache_create(isc_mem_t *cmctx, isc_taskmgr_t *taskmgr,
+dns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
isc_timermgr_t *timermgr, dns_rdataclass_t rdclass,
const char *cachename, const char *db_type,
unsigned int db_argc, char **db_argv, dns_cache_t **cachep) {
REQUIRE(cachep != NULL);
REQUIRE(*cachep == NULL);
- REQUIRE(cmctx != NULL);
+ REQUIRE(mctx != NULL);
REQUIRE(taskmgr != NULL || strcmp(db_type, "rbt") != 0);
REQUIRE(cachename != NULL);
- cache = isc_mem_get(cmctx, sizeof(*cache));
+ cache = isc_mem_get(mctx, sizeof(*cache));
*cache = (dns_cache_t){
- .db_type = isc_mem_strdup(cmctx, db_type),
+ .db_type = isc_mem_strdup(mctx, db_type),
.rdclass = rdclass,
.db_argc = db_argc,
.name = cachename == NULL ? NULL
- : isc_mem_strdup(cmctx, cachename),
+ : isc_mem_strdup(mctx, cachename),
.magic = CACHE_MAGIC,
};
- isc_mem_attach(cmctx, &cache->mctx);
+ isc_mutex_init(&cache->lock);
+ isc_mem_attach(mctx, &cache->mctx);
if (taskmgr != NULL) {
isc_taskmgr_attach(taskmgr, &cache->taskmgr);
}
- isc_mutex_init(&cache->lock);
isc_refcount_init(&cache->references, 1);
isc_refcount_init(&cache->live_tasks, 1);
- result = isc_stats_create(cmctx, &cache->stats,
+ result = isc_stats_create(mctx, &cache->stats,
dns_cachestatscounter_max);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
if (cache->db_argc != 0) {
- cache->db_argv = isc_mem_get(cmctx,
+ cache->db_argv = isc_mem_get(mctx,
cache->db_argc * sizeof(char *));
for (i = 0; i < cache->db_argc; i++) {
}
for (i = extra; i < cache->db_argc; i++) {
- cache->db_argv[i] = isc_mem_strdup(cmctx,
+ cache->db_argv[i] = isc_mem_strdup(mctx,
db_argv[i - extra]);
}
}
*** Functions
***/
isc_result_t
-dns_cache_create(isc_mem_t *cmctx, isc_taskmgr_t *taskmgr,
+dns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
isc_timermgr_t *timermgr, dns_rdataclass_t rdclass,
const char *cachename, const char *db_type,
unsigned int db_argc, char **db_argv, dns_cache_t **cachep);
*
* Requires:
*
- *\li 'cmctx' are valid memory contexts.
+ *\li 'mctx' is a valid memory context.
*
*\li 'taskmgr' is a valid task manager (if 'db_type' is "rbt").
*
* periodic cleaning of the cache will take place.
*
*\li 'cachename' is a valid string. This must not be NULL.
+
+ *\li 'mctx' is a valid memory context.
*
*\li 'cachep' is a valid pointer, and *cachep == NULL
*