]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix mempool stats bug in the internal allocator
authorMichał Kępień <michal@isc.org>
Fri, 15 Jul 2022 08:23:03 +0000 (10:23 +0200)
committerMichał Kępień <michal@isc.org>
Fri, 15 Jul 2022 08:45:34 +0000 (10:45 +0200)
Commit c96b6eb5ece1d44fdfbce45da2364e3764956822 changed the way mempool
code handles freed allocations that cannot be retained for later use as
"free list" items: it no longer uses different logic depending on
whether the internal allocator is used or the system one.  However, that
commit did not update a relevant piece of code in isc_mempool_destroy(),
causing memory context statistics to always be off upon shutdown when
BIND 9 is built with -DISC_MEM_USE_INTERNAL_MALLOC=1.  This causes
assertion failures.  Update isc_mempool_destroy() accordingly in order
to prevent this issue from being triggered.

lib/isc/mem.c

index ed74d4c0c841c2238f3e6170e15a3fa5093f4f60..d4f6efd5e89fd5b1a2660b548511c5de390c9023 100644 (file)
@@ -1725,13 +1725,8 @@ isc_mempool_destroy(isc_mempool_t **mpctxp) {
                mpctx->freecount--;
                item = mpctx->items;
                mpctx->items = item->next;
-
-               if ((mctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
-                       mem_putunlocked(mctx, item, mpctx->size);
-               } else {
-                       mem_putstats(mctx, item, mpctx->size);
-                       mem_put(mctx, item, mpctx->size);
-               }
+               mem_putstats(mctx, item, mpctx->size);
+               mem_put(mctx, item, mpctx->size);
        }
        MCTXUNLOCK(mctx);