ldb: use tdb directly, not tdb_compat.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 19 Jun 2012 03:13:10 +0000 (12:43 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 19 Jun 2012 03:38:07 +0000 (05:38 +0200)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
lib/ldb-samba/ldb_wrap.c
lib/ldb-samba/wscript_build
lib/ldb/ldb_tdb/ldb_index.c
lib/ldb/ldb_tdb/ldb_search.c
lib/ldb/ldb_tdb/ldb_tdb.c
lib/ldb/ldb_tdb/ldb_tdb.h
lib/ldb/ldb_tdb/ldb_tdb_wrap.c
lib/ldb/wscript
source4/dsdb/samdb/ldb_modules/partition_metadata.c

index b8af8c151f84d103e87a50d8ea75de01208299bf..83a06743bef9ebce865cefbe36cb33a234fec409 100644 (file)
@@ -35,7 +35,7 @@
 #include "dsdb/samdb/samdb.h"
 #include "param/param.h"
 #include "../lib/util/dlinklist.h"
-#include "../lib/tdb_compat/tdb_compat.h"
+#include <tdb.h>
 
 /*
   this is used to catch debug messages from ldb
@@ -320,7 +320,8 @@ int samba_ldb_connect(struct ldb_context *ldb, struct loadparm_context *lp_ctx,
 
 /*
   when we fork() we need to make sure that any open ldb contexts have
-  any open transactions cancelled
+  any open transactions cancelled (ntdb databases doesn't need reopening,
+  as we don't use clear_if_first).
  */
  void ldb_wrap_fork_hook(void)
 {
index 85eb66c1b3a60c652fe50fa46934eda62b1c776c..b0d2dcaa3030cf9ac9bce8651aa71872546e41e1 100644 (file)
@@ -8,7 +8,7 @@ bld.SAMBA_LIBRARY('ldbsamba',
                   source='ldif_handlers.c',
                   autoproto='ldif_handlers_proto.h',
                   public_deps='ldb',
-                  deps='security ndr NDR_DRSBLOBS NDR_DNSP ldbwrap samdb-common SAMDB_SCHEMA tdb_compat pyldb-util errors',
+                  deps='security ndr NDR_DRSBLOBS NDR_DNSP ldbwrap samdb-common SAMDB_SCHEMA tdb pyldb-util errors',
                   private_library=True
                   )
 
index a3848eddb2b73c32bf1d9dd200ab7ef5cddaf29d..d2ef4b89a69b2f54a20331ac9685cc9277bb6a60 100644 (file)
@@ -155,7 +155,7 @@ static int ltdb_dn_list_load(struct ldb_module *module,
        key.dptr = discard_const_p(unsigned char, ldb_dn_get_linearized(dn));
        key.dsize = strlen((char *)key.dptr);
 
-       rec = tdb_fetch_compat(ltdb->idxptr->itdb, key);
+       rec = tdb_fetch(ltdb->idxptr->itdb, key);
        if (rec.dptr == NULL) {
                goto normal_index;
        }
@@ -261,7 +261,7 @@ static int ltdb_dn_list_store(struct ldb_module *module, struct ldb_dn *dn,
        }
 
        if (ltdb->idxptr->itdb == NULL) {
-               ltdb->idxptr->itdb = tdb_open_compat(NULL, 1000, TDB_INTERNAL, O_RDWR, 0, NULL, NULL);
+               ltdb->idxptr->itdb = tdb_open(NULL, 1000, TDB_INTERNAL, O_RDWR, 0);
                if (ltdb->idxptr->itdb == NULL) {
                        return LDB_ERR_OPERATIONS_ERROR;
                }
@@ -270,7 +270,7 @@ static int ltdb_dn_list_store(struct ldb_module *module, struct ldb_dn *dn,
        key.dptr = discard_const_p(unsigned char, ldb_dn_get_linearized(dn));
        key.dsize = strlen((char *)key.dptr);
 
-       rec = tdb_fetch_compat(ltdb->idxptr->itdb, key);
+       rec = tdb_fetch(ltdb->idxptr->itdb, key);
        if (rec.dptr != NULL) {
                list2 = ltdb_index_idxptr(module, rec, false);
                if (list2 == NULL) {
index 46e2d749984f5754d8781f4f6192b3375dc15ab4..5e2050065cb9995702e40c14612e7e72a32062dc 100644 (file)
@@ -32,7 +32,7 @@
  */
 
 #include "ldb_tdb.h"
-#include <lib/tdb_compat/tdb_compat.h>
+#include <tdb.h>
 
 /*
   add one element to a message
@@ -224,7 +224,7 @@ static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn)
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       tdb_data = tdb_fetch_compat(ltdb->tdb, tdb_key);
+       tdb_data = tdb_fetch(ltdb->tdb, tdb_key);
        talloc_free(tdb_key.dptr);
        if (!tdb_data.dptr) {
                return LDB_ERR_NO_SUCH_OBJECT;
@@ -256,7 +256,7 @@ int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_mes
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       tdb_data = tdb_fetch_compat(ltdb->tdb, tdb_key);
+       tdb_data = tdb_fetch(ltdb->tdb, tdb_key);
        talloc_free(tdb_key.dptr);
        if (!tdb_data.dptr) {
                return LDB_ERR_NO_SUCH_OBJECT;
index 3541f9109fa16daf97f078a79cb6643d4eb653e9..14ffcf418c758e745f4bc648582c0ecd4c4ac7f7 100644 (file)
@@ -50,7 +50,7 @@
  */
 
 #include "ldb_tdb.h"
-#include <lib/tdb_compat/tdb_compat.h>
+#include <tdb.h>
 
 /*
   prevent memory errors on callbacks
@@ -664,7 +664,7 @@ int ltdb_modify_internal(struct ldb_module *module,
                return LDB_ERR_OTHER;
        }
 
-       tdb_data = tdb_fetch_compat(ltdb->tdb, tdb_key);
+       tdb_data = tdb_fetch(ltdb->tdb, tdb_key);
        if (!tdb_data.dptr) {
                talloc_free(tdb_key.dptr);
                return ltdb_err_map(tdb_error(ltdb->tdb));
index 3b87b56bfd505adcdd55e6f54059b0c5057aafc9..c89dd7f1ae48bc5ac3266592b85b478375a55b80 100644 (file)
@@ -1,7 +1,7 @@
 #include "replace.h"
 #include "system/filesys.h"
 #include "system/time.h"
-#include "tdb_compat.h"
+#include "tdb.h"
 #include "ldb_module.h"
 
 /* this private structure is used by the ltdb backend in the
index 014a756d6e3ac258359747aab4c92b18f2e803a3..eb168098a75a021620a553b1ee360bc7572c3fc1 100644 (file)
@@ -99,6 +99,7 @@ struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,
                                   struct ldb_context *ldb)
 {
        struct ltdb_wrap *w;
+       struct tdb_logging_context lctx;
        struct stat st;
 
        if (stat(path, &st) == 0) {
@@ -117,7 +118,10 @@ struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
-       w->tdb = tdb_open_compat(path, hash_size, tdb_flags, open_flags, mode, ltdb_log_fn, ldb);
+       lctx.log_fn = ltdb_log_fn;
+       lctx.log_private = ldb;
+       w->tdb = tdb_open_ex(path, hash_size, tdb_flags, open_flags, mode,
+                            &lctx, NULL);
        if (w->tdb == NULL) {
                talloc_free(w);
                return NULL;
index f62bdec90f48f4ea7793d18b4e894f8f4eafb1a3..94a9682df900f23d5a4db4164f6f5f8139bcd188 100755 (executable)
@@ -16,24 +16,23 @@ sys.path.insert(0, srcdir + '/buildtools/wafsamba')
 import wafsamba, samba_dist, Options
 
 samba_dist.DIST_DIRS('''lib/ldb:. lib/replace:lib/replace lib/talloc:lib/talloc
-                        lib/tdb:lib/tdb lib/tdb2:lib/tdb2 lib/tdb_compat:lib/tdb_compat lib/ccan:lib/ccan lib/tevent:lib/tevent lib/popt:lib/popt
+                        lib/tdb:lib/tdb lib/tdb2:lib/tdb2 lib/tdb:lib/tdb lib/ccan:lib/ccan lib/tevent:lib/tevent lib/popt:lib/popt
                         buildtools:buildtools''')
 
 
 def set_options(opt):
     opt.BUILTIN_DEFAULT('replace')
     opt.PRIVATE_EXTENSION_DEFAULT('ldb', noextension='ldb')
-    opt.RECURSE('lib/tdb_compat')
+    opt.RECURSE('lib/tdb')
     opt.RECURSE('lib/tevent')
     opt.RECURSE('lib/replace')
     opt.tool_options('python') # options for disabling pyc or pyo compilation
 
 def configure(conf):
-    conf.RECURSE('lib/tdb_compat')
+    conf.RECURSE('lib/tdb')
     conf.RECURSE('lib/tevent')
     conf.RECURSE('lib/popt')
     conf.RECURSE('lib/replace')
-    conf.RECURSE('lib/tdb_compat')
     conf.find_program('python', var='PYTHON')
     conf.find_program('xsltproc', var='XSLTPROC')
     conf.check_tool('python')
@@ -78,11 +77,10 @@ def configure(conf):
     conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
 
 def build(bld):
-    bld.RECURSE('lib/tdb_compat')
     bld.RECURSE('lib/tevent')
     bld.RECURSE('lib/popt')
     bld.RECURSE('lib/replace')
-    bld.RECURSE('lib/tdb_compat')
+    bld.RECURSE('lib/tdb')
 
     if bld.env.standalone_ldb:
         private_library = False
@@ -238,14 +236,14 @@ def build(bld):
                          init_function='ldb_tdb_init',
                          module_init_name='ldb_init_module',
                          internal_module=False,
-                         deps='tdb_compat ldb',
+                         deps='tdb ldb',
                          subsystem='ldb')
 
         # have a separate subsystem for common/ldb.c, so it can rebuild
         # for install with a different -DLDB_MODULESDIR=
         bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
                             'common/ldb.c',
-                            deps='tevent tdb_compat',
+                            deps='tevent tdb',
                             includes='include',
                             cflags=['-DLDB_MODULESDIR=\"%s\"' % modules_dir])
 
index 76b78dd13fa0edb543854a5f3de5c6422eb6352a..8e97b528027aa011849a9b143aefc518d257ed63 100644 (file)
@@ -54,14 +54,14 @@ static int partition_metadata_get_uint64(struct ldb_module *module,
        tdb_key.dptr = (uint8_t *)discard_const_p(char, key);
        tdb_key.dsize = strlen(key);
 
-       tdb_data = tdb_fetch_compat(tdb, tdb_key);
+       tdb_data = tdb_fetch(tdb, tdb_key);
        if (!tdb_data.dptr) {
                if (tdb_error(tdb) == TDB_ERR_NOEXIST) {
                        *value = default_value;
                        return LDB_SUCCESS;
                } else {
                        return ldb_module_error(module, LDB_ERR_OPERATIONS_ERROR,
-                                               tdb_errorstr_compat(tdb));
+                                               tdb_errorstr(tdb));
                }
        }
 
@@ -131,7 +131,7 @@ static int partition_metadata_set_uint64(struct ldb_module *module,
        if (tdb_store(tdb, tdb_key, tdb_data, tdb_flag) != 0) {
                talloc_free(tmp_ctx);
                return ldb_module_error(module, LDB_ERR_OPERATIONS_ERROR,
-                                       tdb_errorstr_compat(tdb));
+                                       tdb_errorstr(tdb));
        }
 
        talloc_free(tmp_ctx);
@@ -398,7 +398,7 @@ int partition_metadata_start_trans(struct ldb_module *module)
 
        if (tdb_transaction_start(tdb) != 0) {
                return ldb_module_error(module, LDB_ERR_OPERATIONS_ERROR,
-                                       tdb_errorstr_compat(tdb));
+                                       tdb_errorstr(tdb));
        }
 
        data->metadata->in_transaction++;
@@ -430,7 +430,7 @@ int partition_metadata_prepare_commit(struct ldb_module *module)
 
        if (tdb_transaction_prepare_commit(tdb) != 0) {
                return ldb_module_error(module, LDB_ERR_OPERATIONS_ERROR,
-                                       tdb_errorstr_compat(tdb));
+                                       tdb_errorstr(tdb));
        }
 
        return LDB_SUCCESS;
@@ -462,7 +462,7 @@ int partition_metadata_end_trans(struct ldb_module *module)
 
        if (tdb_transaction_commit(tdb) != 0) {
                return ldb_module_error(module, LDB_ERR_OPERATIONS_ERROR,
-                                       tdb_errorstr_compat(tdb));
+                                       tdb_errorstr(tdb));
        }
 
        return LDB_SUCCESS;