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
/* 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;
}