ldb_wrap: Remove the magic cache of database handles except for sam.ldb
authorAndrew Bartlett <abartlet@samba.org>
Thu, 15 Mar 2018 00:44:52 +0000 (13:44 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 12 Apr 2018 03:15:17 +0000 (05:15 +0200)
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 <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
lib/ldb-samba/ldb_wrap.c

index 8c3bf6f7bf3f3f7be714ee81379efb27929a1f02..53255556e7c96d2d56b06c8ff487dfc860364598 100644 (file)
@@ -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;