On windows, flush the mapping view when syncing content to disk.

FossilOrigin-Name: a828e73dc1ae50189bdf73f60caeb7308738ad7a
This commit is contained in:
drh 2015-03-31 19:40:05 +00:00
commit f9d02f3663
3 changed files with 38 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C Add\sthe\s"mptest"\starget\sto\smain.mk.\s\sChange\sTRUNCATE\sand\sPERSIST\sto\sDELETE\nfor\smptest.c\son\sWindows\sbecause\sof\sproblems\strying\sto\sdelete\sthe\sjournal.
D 2015-03-31T18:05:49.317
C On\swindows,\sflush\sthe\smapping\sview\swhen\ssyncing\scontent\sto\sdisk.
D 2015-03-31T19:40:05.313
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 00d12636df7a5b08af09116bcd6c7bfd49b8b3b4
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -215,7 +215,7 @@ F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
F src/os_unix.c a4dadbc2da41599e99093e91e276c38c17a73b89
F src/os_win.c 23c2d1fab9b44e728e7d3ac0c82d5ac2a96de290
F src/os_win.c 03d27be3a20048ef52a648d5f0a15f5edda9f2a3
F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
F src/pager.c 4120a49ecd37697e28f5ed807f470b9c0b88410c
F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77
@ -1248,7 +1248,8 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 5d533eee049e63b3700f5ef7c28c588afccde57a
R 9e646d8c9c851fc471bfbde27cfe2ec7
P ea697e6d9ff1f4d77774589a02ba4a18feafbf03 45acf6a85150839d591316418dad59ae20ce3aa4
R 00dcdcdf447a25afe74cb2a2ac195e0b
T +closed 45acf6a85150839d591316418dad59ae20ce3aa4
U drh
Z 7401f8256f1a048a9f3296d27a2e41e1
Z e131d4f6392434ebe038899ef79bd289

View File

@ -1 +1 @@
ea697e6d9ff1f4d77774589a02ba4a18feafbf03
a828e73dc1ae50189bdf73f60caeb7308738ad7a

View File

@ -197,8 +197,10 @@ WINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#endif /* SQLITE_OS_WINRT */
/*
** This file mapping API is common to both Win32 and WinRT.
** These file mapping APIs are common to both Win32 and WinRT.
*/
WINBASEAPI BOOL WINAPI FlushViewOfFile(LPCVOID, SIZE_T);
WINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID);
#endif /* SQLITE_WIN32_FILEMAPPING_API */
@ -1083,6 +1085,15 @@ static struct win_syscall {
#define osUuidCreateSequential \
((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[78].pCurrent)
#if !defined(SQLITE_NO_SYNC) && SQLITE_MAX_MMAP_SIZE>0
{ "FlushViewOfFile", (SYSCALL)FlushViewOfFile, 0 },
#else
{ "FlushViewOfFile", (SYSCALL)0, 0 },
#endif
#define osFlushViewOfFile \
((BOOL(WINAPI*)(LPCVOID,SIZE_T))aSyscall[79].pCurrent)
}; /* End of the overrideable system calls */
/*
@ -2788,6 +2799,22 @@ static int winSync(sqlite3_file *id, int flags){
osGetCurrentProcessId(), pFile, pFile->h));
return SQLITE_OK;
#else
#if SQLITE_MAX_MMAP_SIZE>0
if( pFile->pMapRegion ){
if( osFlushViewOfFile(pFile->pMapRegion, 0) ){
OSTRACE(("SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, "
"rc=SQLITE_OK\n", osGetCurrentProcessId(),
pFile, pFile->pMapRegion));
}else{
pFile->lastErrno = osGetLastError();
OSTRACE(("SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, "
"rc=SQLITE_IOERR_MMAP\n", osGetCurrentProcessId(),
pFile, pFile->pMapRegion));
return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,
"winSync1", pFile->zPath);
}
}
#endif
rc = osFlushFileBuffers(pFile->h);
SimulateIOError( rc=FALSE );
if( rc ){
@ -2799,7 +2826,7 @@ static int winSync(sqlite3_file *id, int flags){
OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_FSYNC\n",
osGetCurrentProcessId(), pFile, pFile->h));
return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,
"winSync", pFile->zPath);
"winSync2", pFile->zPath);
}
#endif
}
@ -5573,7 +5600,7 @@ int sqlite3_os_init(void){
/* Double-check that the aSyscall[] array has been constructed
** correctly. See ticket [bb3a86e890c8e96ab] */
assert( ArraySize(aSyscall)==79 );
assert( ArraySize(aSyscall)==80 );
/* get memory map allocation granularity */
memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));