Change _talloc_total_mem_internal() to ignore memory allocated from a pool when calcu...
authorJeremy Allison <jra@samba.org>
Tue, 27 Aug 2013 19:46:09 +0000 (12:46 -0700)
committerStefan Metzmacher <metze@samba.org>
Tue, 10 Mar 2015 09:55:36 +0000 (10:55 +0100)
We must only count normal tallocs, or a talloc pool itself.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Simo Sorce <idra@samba.org>
(cherry picked from commit 4159a78ed7eda340758e22286f16186987a20f2f)

lib/talloc/talloc.c

index 7b827ca0c15cb3ddb685a6bd3fab8eb54dd844d1..1e25dfde4e1e998872276ef3acb1eec80606cb25 100644 (file)
@@ -1817,7 +1817,14 @@ static size_t _talloc_total_mem_internal(const void *ptr,
                break;
        case TOTAL_MEM_LIMIT:
                if (likely(tc->name != TALLOC_MAGIC_REFERENCE)) {
-                       total = tc->size + TC_HDR_SIZE;
+                       /*
+                        * Don't count memory allocated from a pool
+                        * when calculating limits. Only count the
+                        * pool itself.
+                        */
+                       if (!(tc->flags & TALLOC_FLAG_POOLMEM)) {
+                               total = tc->size + TC_HDR_SIZE;
+                       }
                }
                break;
        }