2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Support ondestroy notification for isc_mem_t.

This commit is contained in:
James Brister
2000-02-10 16:10:41 +00:00
parent 71a1b26df0
commit 80d19f3523
2 changed files with 24 additions and 0 deletions

View File

@@ -97,6 +97,7 @@ struct stats {
struct isc_mem {
unsigned int magic;
isc_ondestroy_t ondestroy;
isc_mutex_t lock;
isc_memalloc_t memalloc;
isc_memfree_t memfree;
@@ -248,6 +249,7 @@ isc_mem_createx(size_t init_max_size, size_t target_size,
ctx->quota = 0;
ctx->total = 0;
ctx->magic = MEM_MAGIC;
isc_ondestroy_init(&ctx->ondestroy);
ISC_LIST_INIT(ctx->pools);
*ctxp = ctx;
@@ -267,6 +269,7 @@ void
isc_mem_destroy(isc_mem_t **ctxp) {
unsigned int i;
isc_mem_t *ctx;
isc_ondestroy_t ondest;
REQUIRE(ctxp != NULL);
ctx = *ctxp;
@@ -294,12 +297,28 @@ isc_mem_destroy(isc_mem_t **ctxp) {
(ctx->memfree)(ctx->arg, ctx->stats);
(ctx->memfree)(ctx->arg, ctx->basic_table);
ondest = ctx->ondestroy;
(void)isc_mutex_destroy(&ctx->lock);
(ctx->memfree)(ctx->arg, ctx);
isc_ondestroy_notify(&ondest, ctx);
*ctxp = NULL;
}
isc_result_t
isc_mem_ondestroy(isc_mem_t *ctx, isc_task_t *task, isc_event_t **event) {
isc_result_t res;
LOCK(&ctx->lock);
res = isc_ondestroy_register(&ctx->ondestroy, task, event);
UNLOCK(&ctx->lock);
return (res);
}
isc_result_t
isc_mem_restore(isc_mem_t *ctx) {
isc_result_t result;