summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-12-09 14:37:26 +1100
committerAndrew Tridgell <tridge@samba.org>2009-12-09 18:18:25 +1100
commit4bb2958f16cc6af43d113528407d53f0d78b0486 (patch)
tree02e61630519cf1ac25e334af10aca77bf1055bb4 /source4/lib/ldb/ldb_tdb
parente5a478d3a23c1d9bb7ebd8c836a0c0a880839e34 (diff)
downloadsamba-4bb2958f16cc6af43d113528407d53f0d78b0486.tar.gz
samba-4bb2958f16cc6af43d113528407d53f0d78b0486.tar.bz2
samba-4bb2958f16cc6af43d113528407d53f0d78b0486.zip
s4-ldb: fixed nested searches inside ldb modules
We need to keep a search count in ltdb to allow for nesting of searches inside a module Signed-off-by: Andrew Tridgell <tridge@samba.org>
Diffstat (limited to 'source4/lib/ldb/ldb_tdb')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c15
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.h1
2 files changed, 12 insertions, 4 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index 7fb3cdc067..48409f2cba 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -88,10 +88,16 @@ int ltdb_lock_read(struct ldb_module *module)
{
void *data = ldb_module_get_private(module);
struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
- if (ltdb->in_transaction == 0) {
- return tdb_lockall_read(ltdb->tdb);
+ int ret = 0;
+
+ if (ltdb->in_transaction == 0 &&
+ ltdb->read_lock_count == 0) {
+ ret = tdb_lockall_read(ltdb->tdb);
}
- return 0;
+ if (ret == 0) {
+ ltdb->read_lock_count++;
+ }
+ return ret;
}
/*
@@ -101,9 +107,10 @@ int ltdb_unlock_read(struct ldb_module *module)
{
void *data = ldb_module_get_private(module);
struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
- if (ltdb->in_transaction == 0) {
+ if (ltdb->in_transaction == 0 && ltdb->read_lock_count == 1) {
return tdb_unlockall_read(ltdb->tdb);
}
+ ltdb->read_lock_count--;
return 0;
}
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.h b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
index 0f17c82eaa..bb4cb3f8b5 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
@@ -31,6 +31,7 @@ struct ltdb_private {
bool check_base;
struct ltdb_idxptr *idxptr;
bool prepared_commit;
+ int read_lock_count;
};
/*