diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-05-01 12:34:12 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:16:25 -0500 |
commit | 425350bb618b7168de1d5d808c9ac5a76d84fcf0 (patch) | |
tree | 36103a51f2935869225ce7cebeb3f8bd567d54aa /source4/lib/ldb/ldb_tdb/ldb_tdb.c | |
parent | d448b73b5c80d73a7bdb3a669d9660c0a67da336 (diff) | |
download | samba-425350bb618b7168de1d5d808c9ac5a76d84fcf0.tar.gz samba-425350bb618b7168de1d5d808c9ac5a76d84fcf0.tar.bz2 samba-425350bb618b7168de1d5d808c9ac5a76d84fcf0.zip |
r6560: added a tdb_chainlock_read() call in ldb_search(). This guarantees
that ldb_search() sees a single consistent view of the database (by
blocking writes during a ldb_search)
(This used to be commit 917f2a8a073fd501f0626bea4f9deb91b95fdc90)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb/ldb_tdb.c')
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_tdb.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index 87582cf4eb..b47d79de52 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -249,6 +249,40 @@ static int ltdb_unlock(struct ldb_module *module, const char *lockname) /* + lock the database for read - use by ltdb_search +*/ +int ltdb_lock_read(struct ldb_module *module) +{ + struct ltdb_private *ltdb = module->private_data; + TDB_DATA key; + int ret; + key = ltdb_key(module, LDBLOCK); + if (!key.dptr) { + return -1; + } + ret = tdb_chainlock_read(ltdb->tdb, key); + talloc_free(key.dptr); + return ret; +} + +/* + unlock the database after a ltdb_lock_read() +*/ +int ltdb_unlock_read(struct ldb_module *module) +{ + struct ltdb_private *ltdb = module->private_data; + TDB_DATA key; + key = ltdb_key(module, LDBLOCK); + if (!key.dptr) { + return -1; + } + tdb_chainunlock_read(ltdb->tdb, key); + talloc_free(key.dptr); + return 0; +} + + +/* we've made a modification to a dn - possibly reindex and update sequence number */ |