@ -2643,7 +2643,7 @@ fail:
}
}
int
int
mdb_env_sync ( MDB_env * env , int force )
mdb_env_sync0 ( MDB_env * env , int force , pgno_t numpgs )
{
{
int rc = 0 ;
int rc = 0 ;
if ( env - > me_flags & MDB_RDONLY )
if ( env - > me_flags & MDB_RDONLY )
@ -2652,7 +2652,7 @@ mdb_env_sync(MDB_env *env, int force)
if ( env - > me_flags & MDB_WRITEMAP ) {
if ( env - > me_flags & MDB_WRITEMAP ) {
int flags = ( ( env - > me_flags & MDB_MAPASYNC ) & & ! force )
int flags = ( ( env - > me_flags & MDB_MAPASYNC ) & & ! force )
? MS_ASYNC : MS_SYNC ;
? MS_ASYNC : MS_SYNC ;
if ( MDB_MSYNC ( env - > me_map , env - > me_ma psize , flags ) )
if ( MDB_MSYNC ( env - > me_map , env - > me_psize * numpgs , flags ) )
rc = ErrCode ( ) ;
rc = ErrCode ( ) ;
# ifdef _WIN32
# ifdef _WIN32
else if ( flags = = MS_SYNC & & MDB_FDATASYNC ( env - > me_fd ) )
else if ( flags = = MS_SYNC & & MDB_FDATASYNC ( env - > me_fd ) )
@ -2672,6 +2672,13 @@ mdb_env_sync(MDB_env *env, int force)
return rc ;
return rc ;
}
}
int
mdb_env_sync ( MDB_env * env , int force )
{
MDB_meta * m = mdb_env_pick_meta ( env ) ;
return mdb_env_sync0 ( env , force , m - > mm_last_pg + 1 ) ;
}
/** Back up parent txn's cursors, then grab the originals for tracking */
/** Back up parent txn's cursors, then grab the originals for tracking */
static int
static int
mdb_cursor_shadow ( MDB_txn * src , MDB_txn * dst )
mdb_cursor_shadow ( MDB_txn * src , MDB_txn * dst )
@ -3813,7 +3820,7 @@ mdb_txn_commit(MDB_txn *txn)
if ( ( rc = mdb_page_flush ( txn , 0 ) ) )
if ( ( rc = mdb_page_flush ( txn , 0 ) ) )
goto fail ;
goto fail ;
if ( ! F_ISSET ( txn - > mt_flags , MDB_TXN_NOSYNC ) & &
if ( ! F_ISSET ( txn - > mt_flags , MDB_TXN_NOSYNC ) & &
( rc = mdb_env_sync ( env , 0 ) ) )
( rc = mdb_env_sync0 ( env , 0 , txn - > mt_next_pgno ) ) )
goto fail ;
goto fail ;
if ( ( rc = mdb_env_write_meta ( txn ) ) )
if ( ( rc = mdb_env_write_meta ( txn ) ) )
goto fail ;
goto fail ;