summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2011-10-18 11:21:34 +1100
committerAndrew Tridgell <tridge@samba.org>2011-10-18 03:54:42 +0200
commit75953f18469fa8746d9d8ad20bbbb3bcbd0df9dd (patch)
treed4daa3fa116d9e7b792e34eda406e8dfba538195 /lib
parent3a4fa654d5ba42ae78a132f54a7edfa722b367f0 (diff)
downloadsamba-75953f18469fa8746d9d8ad20bbbb3bcbd0df9dd.tar.gz
samba-75953f18469fa8746d9d8ad20bbbb3bcbd0df9dd.tar.bz2
samba-75953f18469fa8746d9d8ad20bbbb3bcbd0df9dd.zip
ldb: fixed a race in ldb initialisation
This fixes a race when two processes initialise the same ldb database at the same time. One of them could fail due to the other creating the @BASEINFO record first. Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org> Autobuild-User: Andrew Tridgell <tridge@samba.org> Autobuild-Date: Tue Oct 18 03:54:42 CEST 2011 on sn-devel-104
Diffstat (limited to 'lib')
-rw-r--r--lib/ldb/ldb_tdb/ldb_cache.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/ldb/ldb_tdb/ldb_cache.c b/lib/ldb/ldb_tdb/ldb_cache.c
index e54ceaaa98..0b93021884 100644
--- a/lib/ldb/ldb_tdb/ldb_cache.c
+++ b/lib/ldb/ldb_tdb/ldb_cache.c
@@ -308,9 +308,17 @@ int ltdb_cache_load(struct ldb_module *module)
/* possibly initialise the baseinfo */
if (r == LDB_ERR_NO_SUCH_OBJECT) {
- if (ltdb_baseinfo_init(module) != LDB_SUCCESS) {
+
+ if (tdb_transaction_start(ltdb->tdb) != 0) {
goto failed;
}
+
+ /* error handling for ltdb_baseinfo_init() is by
+ looking for the record again. */
+ ltdb_baseinfo_init(module);
+
+ tdb_transaction_commit(ltdb->tdb);
+
if (ltdb_search_dn1(module, baseinfo_dn, baseinfo) != LDB_SUCCESS) {
goto failed;
}