From 75953f18469fa8746d9d8ad20bbbb3bcbd0df9dd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 18 Oct 2011 11:21:34 +1100 Subject: 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 Autobuild-User: Andrew Tridgell Autobuild-Date: Tue Oct 18 03:54:42 CEST 2011 on sn-devel-104 --- lib/ldb/ldb_tdb/ldb_cache.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib') 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; } -- cgit