lib ldb key_value: Remove index cache lazy initialisation
authorGary Lockyer <gary@catalyst.net.nz>
Mon, 1 Apr 2019 00:12:20 +0000 (13:12 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 4 Apr 2019 06:40:16 +0000 (06:40 +0000)
Remove the lazy initialisation of the index cache. This make setting
the size of the cache for re-indexing easier, which will be done in
later commits.

Performance testing shows that the removal of lazy initialisation makes
no appreciable difference to performance.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/ldb_key_value/ldb_kv_index.c

index 4dfcc2cb0ba916f918de46aeff06aa50ecf0da78..e8b2c824b6cccc39fbaf4cceba9310f86bfd0620 100644 (file)
@@ -208,6 +208,11 @@ int ldb_kv_index_transaction_start(struct ldb_module *module)
                return ldb_oom(ldb_module_get_ctx(module));
        }
 
+       ldb_kv->idxptr->itdb = tdb_open(NULL, 1000, TDB_INTERNAL, O_RDWR, 0);
+       if (ldb_kv->idxptr->itdb == NULL) {
+               return LDB_ERR_OPERATIONS_ERROR;
+       }
+
        return LDB_SUCCESS;
 }
 
@@ -717,14 +722,6 @@ static int ldb_kv_dn_list_store(struct ldb_module *module,
                return ldb_kv_dn_list_store_full(module, ldb_kv, dn, list);
        }
 
-       if (ldb_kv->idxptr->itdb == NULL) {
-               ldb_kv->idxptr->itdb =
-                   tdb_open(NULL, 1000, TDB_INTERNAL, O_RDWR, 0);
-               if (ldb_kv->idxptr->itdb == NULL) {
-                       return LDB_ERR_OPERATIONS_ERROR;
-               }
-       }
-
        key.dptr = discard_const_p(unsigned char, ldb_dn_get_linearized(dn));
        if (key.dptr == NULL) {
                return LDB_ERR_OPERATIONS_ERROR;