summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb/ldb_tdb.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-20 00:59:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:29:45 -0500
commit338c3f8523d5db2cba1b79f94ff0cecabcd9e9cd (patch)
tree9cbd8fa10fbb46b70fe1a2783bc30689f3d652ba /source4/lib/ldb/ldb_tdb/ldb_tdb.c
parentf650ea10120d41ceff8ea04975fea7637cb45a0a (diff)
downloadsamba-338c3f8523d5db2cba1b79f94ff0cecabcd9e9cd.tar.gz
samba-338c3f8523d5db2cba1b79f94ff0cecabcd9e9cd.tar.bz2
samba-338c3f8523d5db2cba1b79f94ff0cecabcd9e9cd.zip
r8625: move the ldb_wrap logic into the ldb code. This logic is meant to
avoid the horrors of posix locking, but it was preventing us having an ldb open twice with different options. Now each ldb open of the same file shares the same underlying tdb, but uses a different ldb structure (This used to be commit 4e090c66dfa1d2764e4693578d3845be3b8893f6)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb/ldb_tdb.c')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index 0c8d2cea3e..40cfe97c29 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -819,16 +819,6 @@ static const struct ldb_module_ops ltdb_ops = {
/*
- destroy the ltdb context
-*/
-static int ltdb_destructor(void *p)
-{
- struct ltdb_private *ltdb = p;
- tdb_close(ltdb->tdb);
- return 0;
-}
-
-/*
connect to the database
*/
int ltdb_connect(struct ldb_context *ldb, const char *url,
@@ -837,7 +827,6 @@ int ltdb_connect(struct ldb_context *ldb, const char *url,
const char *path;
int tdb_flags, open_flags;
struct ltdb_private *ltdb;
- TDB_CONTEXT *tdb;
/* parse the url */
if (strchr(url, ':')) {
@@ -858,24 +847,21 @@ int ltdb_connect(struct ldb_context *ldb, const char *url,
open_flags = O_CREAT | O_RDWR;
}
- /* note that we use quite a large default hash size */
- tdb = tdb_open(path, 10000, tdb_flags, open_flags, 0666);
- if (!tdb) {
- ldb_debug(ldb, LDB_DEBUG_ERROR, "Unable to open tdb '%s'\n", path);
- return -1;
- }
-
ltdb = talloc_zero(ldb, struct ltdb_private);
if (!ltdb) {
- tdb_close(tdb);
ldb_oom(ldb);
return -1;
}
- ltdb->tdb = tdb;
- ltdb->sequence_number = 0;
+ /* note that we use quite a large default hash size */
+ ltdb->tdb = ltdb_wrap_open(ltdb, path, 10000, tdb_flags, open_flags, 0666);
+ if (!ltdb->tdb) {
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "Unable to open tdb '%s'\n", path);
+ talloc_free(ltdb);
+ return -1;
+ }
- talloc_set_destructor(ltdb, ltdb_destructor);
+ ltdb->sequence_number = 0;
ldb->modules = talloc(ldb, struct ldb_module);
if (!ldb->modules) {