mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-22 15:49:34 -05:00
Try to avoid an invalid datafile after failed init
This commit is contained in:
parent
aa10c98f3f
commit
f3d3f60e3d
1 changed files with 14 additions and 0 deletions
|
|
@ -4008,6 +4008,20 @@ mdb_env_open2(MDB_env *env)
|
||||||
}
|
}
|
||||||
meta.mm_mapsize = env->me_mapsize;
|
meta.mm_mapsize = env->me_mapsize;
|
||||||
|
|
||||||
|
if (newenv && !(flags & MDB_FIXEDMAP)) {
|
||||||
|
/* mdb_env_map() may grow the datafile. Write the metapages
|
||||||
|
* first, so the file will be valid if initialization fails.
|
||||||
|
* Except with FIXEDMAP, since we do not yet know mm_address.
|
||||||
|
* We could fill in mm_address later, but then a different
|
||||||
|
* program might end up doing that - one with a memory layout
|
||||||
|
* and map address which does not suit the main program.
|
||||||
|
*/
|
||||||
|
rc = mdb_env_init_meta(env, &meta);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
newenv = 0;
|
||||||
|
}
|
||||||
|
|
||||||
rc = mdb_env_map(env, (flags & MDB_FIXEDMAP) ? meta.mm_address : NULL);
|
rc = mdb_env_map(env, (flags & MDB_FIXEDMAP) ? meta.mm_address : NULL);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue