summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-10-15 21:31:58 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:21:03 -0500
commitba68ee4cd40ca6a5d17fedf621bc17d966d9bd48 (patch)
tree19ed6ab77710ebb19a8923e28ed24112f264aa59
parent3df891a5af0137b0215235cad6f06446df160782 (diff)
downloadsamba-ba68ee4cd40ca6a5d17fedf621bc17d966d9bd48.tar.gz
samba-ba68ee4cd40ca6a5d17fedf621bc17d966d9bd48.tar.bz2
samba-ba68ee4cd40ca6a5d17fedf621bc17d966d9bd48.zip
r19296: added a leak detector to ldb_wrap_connect()
this makes 'make test' _very_ noisy, apologies for that, but nearly all the noise is real memory leaks, so if you don't like it then jump in and help fix the leaks :) (This used to be commit d791fd7b7b7a0a2674a70afe6cbbf0e3bd014544)
-rw-r--r--source4/lib/db_wrap.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/source4/lib/db_wrap.c b/source4/lib/db_wrap.c
index b7a6a17ef8..de6e8a2c0b 100644
--- a/source4/lib/db_wrap.c
+++ b/source4/lib/db_wrap.c
@@ -65,6 +65,21 @@ char *wrap_casefold(void *context, void *mem_ctx, const char *s)
return strupper_talloc(mem_ctx, s);
}
+/* check for leaks */
+static int ldb_wrap_destructor(struct ldb_context *ldb)
+{
+ if (talloc_total_blocks(ldb) > 300) {
+ DEBUG(0,("WARNING: probable memory leak in ldb %s - %lu blocks %lu bytes\n",
+ (char *)ldb_get_opaque(ldb, "wrap_url"),
+ (unsigned long)talloc_total_blocks(ldb),
+ (unsigned long)talloc_total_size(ldb)));
+#if 0
+ talloc_report_full(ldb, stdout);
+#endif
+ }
+ return 0;
+}
+
/*
wrapped connection to a ldb database
to close just talloc_free() the returned ldb_context
@@ -136,12 +151,13 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
return NULL;
}
- talloc_free(real_url);
-
ldb_set_debug(ldb, ldb_wrap_debug, NULL);
ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+ ldb_set_opaque(ldb, "wrap_url", real_url);
+ talloc_set_destructor(ldb, ldb_wrap_destructor);
+
return ldb;
}