mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 03:19:59 -04:00
Add debug tracing capability to isc_mempool_create/destroy
Previously, we only had capability to trace the mempool gets and puts, but for debugging, it's sometimes also important to keep track how many and where do the memory pools get created and destroyed. This commit adds such tracking capability.
This commit is contained in:
parent
5ab05d1696
commit
fd3ceec475
2 changed files with 24 additions and 4 deletions
|
|
@ -361,8 +361,11 @@ isc_mem_renderjson(void *memobj0);
|
|||
* Memory pools
|
||||
*/
|
||||
|
||||
#define isc_mempool_create(c, s, mp) \
|
||||
isc__mempool_create((c), (s), (mp)_ISC_MEM_FILELINE)
|
||||
void
|
||||
isc_mempool_create(isc_mem_t *mctx, size_t size, isc_mempool_t **mpctxp);
|
||||
isc__mempool_create(isc_mem_t *mctx, size_t size,
|
||||
isc_mempool_t **mpctxp _ISC_MEM_FLARG);
|
||||
/*%<
|
||||
* Create a memory pool.
|
||||
*
|
||||
|
|
@ -381,8 +384,9 @@ isc_mempool_create(isc_mem_t *mctx, size_t size, isc_mempool_t **mpctxp);
|
|||
*\li #ISC_R_SUCCESS -- all is well.
|
||||
*/
|
||||
|
||||
#define isc_mempool_destroy(mp) isc__mempool_destroy((mp)_ISC_MEM_FILELINE)
|
||||
void
|
||||
isc_mempool_destroy(isc_mempool_t **mpctxp);
|
||||
isc__mempool_destroy(isc_mempool_t **mpctxp _ISC_MEM_FLARG);
|
||||
/*%<
|
||||
* Destroy a memory pool.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1084,7 +1084,8 @@ isc_mem_getname(isc_mem_t *ctx) {
|
|||
*/
|
||||
|
||||
void
|
||||
isc_mempool_create(isc_mem_t *mctx, size_t size, isc_mempool_t **mpctxp) {
|
||||
isc__mempool_create(isc_mem_t *mctx, size_t size,
|
||||
isc_mempool_t **mpctxp FLARG) {
|
||||
REQUIRE(VALID_CONTEXT(mctx));
|
||||
REQUIRE(size > 0U);
|
||||
REQUIRE(mpctxp != NULL && *mpctxp == NULL);
|
||||
|
|
@ -1117,6 +1118,13 @@ isc_mempool_create(isc_mem_t *mctx, size_t size, isc_mempool_t **mpctxp) {
|
|||
atomic_init(&mpctx->fillcount, 1);
|
||||
atomic_init(&mpctx->gets, 0);
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
if ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0) {
|
||||
fprintf(stderr, "create pool %p file %s line %u mctx %p\n",
|
||||
mpctx, file, line, mctx);
|
||||
}
|
||||
#endif /* ISC_MEM_TRACKLINES */
|
||||
|
||||
*mpctxp = (isc_mempool_t *)mpctx;
|
||||
|
||||
MCTXLOCK(mctx);
|
||||
|
|
@ -1138,7 +1146,7 @@ isc_mempool_setname(isc_mempool_t *mpctx, const char *name) {
|
|||
}
|
||||
|
||||
void
|
||||
isc_mempool_destroy(isc_mempool_t **mpctxp) {
|
||||
isc__mempool_destroy(isc_mempool_t **mpctxp FLARG) {
|
||||
REQUIRE(mpctxp != NULL);
|
||||
REQUIRE(VALID_MEMPOOL(*mpctxp));
|
||||
|
||||
|
|
@ -1149,6 +1157,14 @@ isc_mempool_destroy(isc_mempool_t **mpctxp) {
|
|||
|
||||
mpctx = *mpctxp;
|
||||
*mpctxp = NULL;
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
if ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0) {
|
||||
fprintf(stderr, "destroy pool %p file %s line %u mctx %p\n",
|
||||
mpctx, file, line, mctx);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (atomic_load_acquire(&mpctx->allocated) > 0) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_mempool_destroy(): mempool %s "
|
||||
|
|
|
|||
Loading…
Reference in a new issue