mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
Add mctx attach/detach when creating/destroying a memory pool
This should make sure that the memory context is not destroyed before the memory pool, which is using the context.
This commit is contained in:
parent
774a0277a0
commit
e97c3eea95
@ -1183,8 +1183,6 @@ isc__mempool_create(isc_mem_t *restrict mctx, const size_t element_size,
|
|||||||
mpctx = isc_mem_get(mctx, sizeof(isc_mempool_t));
|
mpctx = isc_mem_get(mctx, sizeof(isc_mempool_t));
|
||||||
|
|
||||||
*mpctx = (isc_mempool_t){
|
*mpctx = (isc_mempool_t){
|
||||||
.magic = MEMPOOL_MAGIC,
|
|
||||||
.mctx = mctx,
|
|
||||||
.size = size,
|
.size = size,
|
||||||
.freemax = 1,
|
.freemax = 1,
|
||||||
.fillcount = 1,
|
.fillcount = 1,
|
||||||
@ -1197,6 +1195,9 @@ isc__mempool_create(isc_mem_t *restrict mctx, const size_t element_size,
|
|||||||
}
|
}
|
||||||
#endif /* ISC_MEM_TRACKLINES */
|
#endif /* ISC_MEM_TRACKLINES */
|
||||||
|
|
||||||
|
isc_mem_attach(mctx, &mpctx->mctx);
|
||||||
|
mpctx->magic = MEMPOOL_MAGIC;
|
||||||
|
|
||||||
*mpctxp = (isc_mempool_t *)mpctx;
|
*mpctxp = (isc_mempool_t *)mpctx;
|
||||||
|
|
||||||
MCTXLOCK(mctx);
|
MCTXLOCK(mctx);
|
||||||
@ -1266,7 +1267,7 @@ isc__mempool_destroy(isc_mempool_t **restrict mpctxp FLARG) {
|
|||||||
|
|
||||||
mpctx->magic = 0;
|
mpctx->magic = 0;
|
||||||
|
|
||||||
isc_mem_put(mpctx->mctx, mpctx, sizeof(isc_mempool_t));
|
isc_mem_putanddetach(&mpctx->mctx, mpctx, sizeof(isc_mempool_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user