1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-15 11:41:13 +03:00

Changes to help SQLite cope with virus scanners and other programs that

open journal files for reading and thus prevent SQLite from deleting
them in order to commit a transaction. (CVS 3200)

FossilOrigin-Name: f32dbe47ffd1e7e5695f02bf4263d80bea177ffb
This commit is contained in:
drh
2006-06-04 23:02:20 +00:00
parent f52fd0bc11
commit eb4fa52a45
3 changed files with 44 additions and 28 deletions

View File

@@ -1,5 +1,5 @@
C Remove\sunused\svariables\sfrom\svdbe.c.\s(CVS\s3199) C Changes\sto\shelp\sSQLite\scope\swith\svirus\sscanners\sand\sother\sprograms\sthat\nopen\sjournal\sfiles\sfor\sreading\sand\sthus\sprevent\sSQLite\sfrom\sdeleting\nthem\sin\sorder\sto\scommit\sa\stransaction.\s(CVS\s3200)
D 2006-06-03T18:04:17 D 2006-06-04T23:02:20
F Makefile.in 87b6d483513ab8a4e763775bc5b434d6b5c34963 F Makefile.in 87b6d483513ab8a4e763775bc5b434d6b5c34963
F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -59,7 +59,7 @@ F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3 F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
F src/os_unix.c 17d91581a0ab478a06cb6f257b707a4c4a93e5a7 F src/os_unix.c 17d91581a0ab478a06cb6f257b707a4c4a93e5a7
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
F src/os_win.c f48550e191c7e37cd8e802b6a84433e9a3b84d3a F src/os_win.c e64e6bdfc42d867fff05f4d7a64ea110d675bcee
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pager.c ddd05666bb89808a516baef2c186d6a75887ae90 F src/pager.c ddd05666bb89808a516baef2c186d6a75887ae90
F src/pager.h 43f32f3847421f7502cfbb66f4eb2302b8033818 F src/pager.h 43f32f3847421f7502cfbb66f4eb2302b8033818
@@ -358,7 +358,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P 373246c2d1edaec1ce248ff875db48ce51d896f9 P d54750aefba0accd66f928e55ae52fe074f2b8da
R b48d479098e93e880ab65de32baab4b2 R 9cbcd05930c9ecc6055d180c4440ce81
U drh U drh
Z 7efde1f713a350fe61db31962972de9c Z 76393d3c5b3afb3e710409c428223801

View File

@@ -1 +1 @@
d54750aefba0accd66f928e55ae52fe074f2b8da f32dbe47ffd1e7e5695f02bf4263d80bea177ffb

View File

@@ -480,18 +480,24 @@ static BOOL winceLockFileEx(
*/ */
int sqlite3WinDelete(const char *zFilename){ int sqlite3WinDelete(const char *zFilename){
WCHAR *zWide = utf8ToUnicode(zFilename); WCHAR *zWide = utf8ToUnicode(zFilename);
int cnt = 0;
int rc;
if( zWide ){ if( zWide ){
DeleteFileW(zWide); do{
rc = DeleteFileW(zWide);
}while( rc==0 && cnt++ < 3 && (Sleep(100), 1) );
sqliteFree(zWide); sqliteFree(zWide);
}else{ }else{
#if OS_WINCE #if OS_WINCE
return SQLITE_NOMEM; return SQLITE_NOMEM;
#else #else
DeleteFileA(zFilename); do{
rc = DeleteFileA(zFilename);
}while( rc==0 && cnt++ < 3 && (Sleep(100), 1) );
#endif #endif
} }
TRACE2("DELETE \"%s\"\n", zFilename); TRACE2("DELETE \"%s\"\n", zFilename);
return SQLITE_OK; return rc==0 ? SQLITE_OK : SQLITE_IOERR;
} }
/* /*
@@ -638,27 +644,33 @@ int sqlite3WinOpenExclusive(const char *zFilename, OsFile **pId, int delFlag){
} }
#endif #endif
if( zWide ){ if( zWide ){
h = CreateFileW(zWide, int cnt = 0;
GENERIC_READ | GENERIC_WRITE, do{
0, h = CreateFileW(zWide,
NULL, GENERIC_READ | GENERIC_WRITE,
CREATE_ALWAYS, 0,
fileflags, NULL,
NULL CREATE_ALWAYS,
); fileflags,
NULL
);
}while( h==INVALID_HANDLE_VALUE && cnt++ < 2 && (Sleep(100), 1) );
sqliteFree(zWide); sqliteFree(zWide);
}else{ }else{
#if OS_WINCE #if OS_WINCE
return SQLITE_NOMEM; return SQLITE_NOMEM;
#else #else
h = CreateFileA(zFilename, int cnt = 0;
GENERIC_READ | GENERIC_WRITE, do{
0, h = CreateFileA(zFilename,
NULL, GENERIC_READ | GENERIC_WRITE,
CREATE_ALWAYS, 0,
fileflags, NULL,
NULL CREATE_ALWAYS,
); fileflags,
NULL
);
}while( h==INVALID_HANDLE_VALUE && cnt++ < 2 && (Sleep(100), 1) );
#endif /* OS_WINCE */ #endif /* OS_WINCE */
} }
if( h==INVALID_HANDLE_VALUE ){ if( h==INVALID_HANDLE_VALUE ){
@@ -799,9 +811,13 @@ int sqlite3WinTempFileName(char *zBuf){
*/ */
static int winClose(OsFile **pId){ static int winClose(OsFile **pId){
winFile *pFile; winFile *pFile;
int rc = 1;
if( pId && (pFile = (winFile*)*pId)!=0 ){ if( pId && (pFile = (winFile*)*pId)!=0 ){
int rc, cnt = 0;
TRACE2("CLOSE %d\n", pFile->h); TRACE2("CLOSE %d\n", pFile->h);
CloseHandle(pFile->h); do{
rc = CloseHandle(pFile->h);
}while( rc==0 && cnt++ < 3 && (Sleep(100), 1) );
#if OS_WINCE #if OS_WINCE
winceDestroyLock(pFile); winceDestroyLock(pFile);
if( pFile->zDeleteOnClose ){ if( pFile->zDeleteOnClose ){
@@ -813,7 +829,7 @@ static int winClose(OsFile **pId){
sqliteFree(pFile); sqliteFree(pFile);
*pId = 0; *pId = 0;
} }
return SQLITE_OK; return rc ? SQLITE_OK : SQLITE_IOERR;
} }
/* /*