mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 16:15:27 +00:00
isc_task_create() API change; attach to mctx
This commit is contained in:
@@ -15,9 +15,10 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: cache.c,v 1.15 2000/04/06 22:01:49 explorer Exp $ */
|
/* $Id: cache.c,v 1.16 2000/04/12 01:37:41 halley Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include <isc/assertions.h>
|
#include <isc/assertions.h>
|
||||||
@@ -133,7 +134,9 @@ dns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
|
|||||||
if (cache == NULL)
|
if (cache == NULL)
|
||||||
return (ISC_R_NOMEMORY);
|
return (ISC_R_NOMEMORY);
|
||||||
|
|
||||||
cache->mctx = mctx;
|
cache->mctx = NULL;
|
||||||
|
isc_mem_attach(mctx, &cache->mctx);
|
||||||
|
|
||||||
result = isc_mutex_init(&cache->lock);
|
result = isc_mutex_init(&cache->lock);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||||
@@ -170,12 +173,15 @@ dns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
|
|||||||
cleanup_mutex:
|
cleanup_mutex:
|
||||||
isc_mutex_destroy(&cache->lock);
|
isc_mutex_destroy(&cache->lock);
|
||||||
cleanup_mem:
|
cleanup_mem:
|
||||||
isc_mem_put(cache->mctx, cache, sizeof *cache);
|
isc_mem_put(mctx, cache, sizeof *cache);
|
||||||
|
isc_mem_detach(&mctx);
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cache_free(dns_cache_t *cache) {
|
cache_free(dns_cache_t *cache) {
|
||||||
|
isc_mem_t *mctx;
|
||||||
|
|
||||||
REQUIRE(VALID_CACHE(cache));
|
REQUIRE(VALID_CACHE(cache));
|
||||||
REQUIRE(cache->references == 0);
|
REQUIRE(cache->references == 0);
|
||||||
|
|
||||||
@@ -198,7 +204,9 @@ cache_free(dns_cache_t *cache) {
|
|||||||
|
|
||||||
isc_mutex_destroy(&cache->lock);
|
isc_mutex_destroy(&cache->lock);
|
||||||
cache->magic = 0;
|
cache->magic = 0;
|
||||||
|
mctx = cache->mctx;
|
||||||
isc_mem_put(cache->mctx, cache, sizeof *cache);
|
isc_mem_put(cache->mctx, cache, sizeof *cache);
|
||||||
|
isc_mem_detach(&mctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -323,8 +331,7 @@ cache_cleaner_init(dns_cache_t *cache, isc_taskmgr_t *taskmgr,
|
|||||||
cleaner->resched_event = NULL;
|
cleaner->resched_event = NULL;
|
||||||
|
|
||||||
if (taskmgr != NULL && timermgr != NULL) {
|
if (taskmgr != NULL && timermgr != NULL) {
|
||||||
result = isc_task_create(taskmgr, cache->mctx,
|
result = isc_task_create(taskmgr, 1, &cleaner->task);
|
||||||
1, &cleaner->task);
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||||
"isc_task_create() failed: %s",
|
"isc_task_create() failed: %s",
|
||||||
|
Reference in New Issue
Block a user