From a7cdec9ded016d6a1996a0d68dc9b7b029e78c7f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 15 Mar 2018 13:44:52 +1300 Subject: ldb_wrap: Remove the magic cache of database handles except for sam.ldb sam.ldb is handled in samdb_connect_url(), not this function. This cache caused issues when "private dir" was changed in a testing script, but also just generates many-owner shared mutable state that is frowned upon these days. Signed-off-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- lib/ldb-samba/ldb_wrap.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lib/ldb-samba') diff --git a/lib/ldb-samba/ldb_wrap.c b/lib/ldb-samba/ldb_wrap.c index 8c3bf6f7bf3..53255556e7c 100644 --- a/lib/ldb-samba/ldb_wrap.c +++ b/lib/ldb-samba/ldb_wrap.c @@ -303,9 +303,13 @@ int samba_ldb_connect(struct ldb_context *ldb, struct loadparm_context *lp_ctx, struct ldb_context *ldb; int ret; - ldb = ldb_wrap_find(url, ev, lp_ctx, session_info, credentials, flags); - if (ldb != NULL) - return talloc_reference(mem_ctx, ldb); + /* + * Unlike samdb_connect_url() do not try and cache the LDB + * handle, get a new one each time. Only sam.ldb is + * punitively expensive to open and helpful caches like this + * cause challenges (such as if the value for 'private dir' + * changes). + */ ldb = samba_ldb_init(mem_ctx, ev, lp_ctx, session_info, credentials); @@ -318,11 +322,6 @@ int samba_ldb_connect(struct ldb_context *ldb, struct loadparm_context *lp_ctx, return NULL; } - if (!ldb_wrap_add(url, ev, lp_ctx, session_info, credentials, flags, ldb)) { - talloc_free(ldb); - return NULL; - } - DEBUG(3,("ldb_wrap open of %s\n", url)); return ldb; -- cgit v1.2.1