summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb/ldb_search.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-09-22 04:40:23 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:38:42 -0500
commitaf352b4664332416a49569618fb6a2ef4099be04 (patch)
treefb8ce2cda4409e3b5f3bf53f7f884d3fd6a399a2 /source4/lib/ldb/ldb_tdb/ldb_search.c
parent6fe9eee3c4dbd6fde48a80261f39081e659d2f55 (diff)
downloadsamba-af352b4664332416a49569618fb6a2ef4099be04.tar.gz
samba-af352b4664332416a49569618fb6a2ef4099be04.tar.bz2
samba-af352b4664332416a49569618fb6a2ef4099be04.zip
r10408: now that we are using tdb transactions we don't need any additional
locking code in the ldb_tdb backend, except for a single read lock during searches to ensure searches don't cross transaction boundaries The tdb transactions code would map these extra locks to noops anyway (as locking makes no sense inside a transaction), but the work in setting up the locking keys still costs something, and it makes the code needlessly complex (This used to be commit 1b8d368a6771360fb0626127c02b3eb95f3eae59)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb/ldb_search.c')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_search.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c
index fc864ac2ea..83079eab81 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_search.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_search.c
@@ -242,6 +242,42 @@ int ltdb_search_dn1(struct ldb_module *module, const struct ldb_dn *dn, struct l
return 1;
}
+/* the lock key for search locking. Note that this is not a DN, its
+ just an arbitrary key to give to tdb. Also note that as we and
+ using transactions for all write operations and transactions take
+ care of their own locks, we don't need to do any locking anywhere
+ other than in ldb_search() */
+#define LDBLOCK "INT_LDBLOCK"
+
+/*
+ lock the database for read - use by ltdb_search
+*/
+static int ltdb_lock_read(struct ldb_module *module)
+{
+ struct ltdb_private *ltdb = module->private_data;
+ TDB_DATA key;
+
+ key.dptr = discard_const(LDBLOCK);
+ key.dsize = strlen(LDBLOCK);
+
+ return tdb_chainlock_read(ltdb->tdb, key);
+}
+
+/*
+ unlock the database after a ltdb_lock_read()
+*/
+static int ltdb_unlock_read(struct ldb_module *module)
+{
+ struct ltdb_private *ltdb = module->private_data;
+ TDB_DATA key;
+
+ key.dptr = discard_const(LDBLOCK);
+ key.dsize = strlen(LDBLOCK);
+
+ return tdb_chainunlock_read(ltdb->tdb, key);
+}
+
+
/*
search the database for a single simple dn