File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -4008,6 +4008,20 @@ mdb_env_open2(MDB_env *env)
4008
4008
}
4009
4009
meta .mm_mapsize = env -> me_mapsize ;
4010
4010
4011
+ if (newenv && !(flags & MDB_FIXEDMAP )) {
4012
+ /* mdb_env_map() may grow the datafile. Write the metapages
4013
+ * first, so the file will be valid if initialization fails.
4014
+ * Except with FIXEDMAP, since we do not yet know mm_address.
4015
+ * We could fill in mm_address later, but then a different
4016
+ * program might end up doing that - one with a memory layout
4017
+ * and map address which does not suit the main program.
4018
+ */
4019
+ rc = mdb_env_init_meta (env , & meta );
4020
+ if (rc )
4021
+ return rc ;
4022
+ newenv = 0 ;
4023
+ }
4024
+
4011
4025
rc = mdb_env_map (env , (flags & MDB_FIXEDMAP ) ? meta .mm_address : NULL );
4012
4026
if (rc )
4013
4027
return rc ;
You can’t perform that action at this time.
0 commit comments