From: drh Date: Sun, 4 Jun 2006 23:31:48 +0000 (+0000) Subject: Add comments to the changes of check-in (3200). (CVS 3202) X-Git-Tag: version-3.6.10~2965 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59e63a6b30135974e9fade249bb52ecd5f95c3b7;p=thirdparty%2Fsqlite.git Add comments to the changes of check-in (3200). (CVS 3202) FossilOrigin-Name: 697498d4e86a42d7063417a9549ad04aaf4db31c --- diff --git a/manifest b/manifest index 86fcb210f9..47848f7264 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\swindows\sportability\sproblem\sin\strans.test.\s(CVS\s3201) -D 2006-06-04T23:20:10 +C Add\scomments\sto\sthe\schanges\sof\scheck-in\s(3200).\s(CVS\s3202) +D 2006-06-04T23:31:49 F Makefile.in 87b6d483513ab8a4e763775bc5b434d6b5c34963 F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -59,7 +59,7 @@ F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3 F src/os_unix.c 17d91581a0ab478a06cb6f257b707a4c4a93e5a7 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e -F src/os_win.c e64e6bdfc42d867fff05f4d7a64ea110d675bcee +F src/os_win.c c6976ae50b61fb5b7dce399e578aa1865f02b84f F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b F src/pager.c ddd05666bb89808a516baef2c186d6a75887ae90 F src/pager.h 43f32f3847421f7502cfbb66f4eb2302b8033818 @@ -358,7 +358,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P f32dbe47ffd1e7e5695f02bf4263d80bea177ffb -R fdbddefcc4faca3a136fc36ee74f50cf +P f2538dfdb608b7f849bfc5fac0ec9d0d8dece4c7 +R 450ca953aa563fb633123fb7704167a9 U drh -Z 3232c1640de3ece87648ffe1a2cfee85 +Z 91538f76d1061379dfa3e8a2e60214bc diff --git a/manifest.uuid b/manifest.uuid index d73d384366..805878d397 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f2538dfdb608b7f849bfc5fac0ec9d0d8dece4c7 \ No newline at end of file +697498d4e86a42d7063417a9549ad04aaf4db31c \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 9ce80ff5cc..6c167ab5b8 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -476,8 +476,18 @@ static BOOL winceLockFileEx( #endif /* OS_WINCE */ /* -** Delete the named file +** Delete the named file. +** +** Note that windows does not allow a file to be deleted if some other +** process has it open. Sometimes a virus scanner or indexing program +** will open a journal file shortly after it is created in order to do +** whatever it is it does. While this other process is holding the +** file open, we will be unable to delete it. To work around this +** problem, we delay 100 milliseconds and try to delete again. Up +** to MX_DELETION_ATTEMPTs deletion attempts are run before giving +** up and returning an error. */ +#define MX_DELETION_ATTEMPTS 3 int sqlite3WinDelete(const char *zFilename){ WCHAR *zWide = utf8ToUnicode(zFilename); int cnt = 0; @@ -485,7 +495,7 @@ int sqlite3WinDelete(const char *zFilename){ if( zWide ){ do{ rc = DeleteFileW(zWide); - }while( rc==0 && cnt++ < 3 && (Sleep(100), 1) ); + }while( rc==0 && cnt++ < MX_DELETION_ATTEMPTS && (Sleep(100), 1) ); sqliteFree(zWide); }else{ #if OS_WINCE @@ -493,7 +503,7 @@ int sqlite3WinDelete(const char *zFilename){ #else do{ rc = DeleteFileA(zFilename); - }while( rc==0 && cnt++ < 3 && (Sleep(100), 1) ); + }while( rc==0 && cnt++ < MX_DELETION_ATTEMPTS && (Sleep(100), 1) ); #endif } TRACE2("DELETE \"%s\"\n", zFilename); @@ -630,6 +640,12 @@ int sqlite3WinOpenReadWrite( ** On success, write the file handle into *id and return SQLITE_OK. ** ** On failure, return SQLITE_CANTOPEN. +** +** Sometimes if we have just deleted a prior journal file, windows +** will fail to open a new one because there is a "pending delete". +** To work around this bug, we pause for 100 milliseconds and attempt +** a second open after the first one fails. The whole operation only +** fails if both open attempts are unsuccessful. */ int sqlite3WinOpenExclusive(const char *zFilename, OsFile **pId, int delFlag){ winFile f; @@ -808,7 +824,15 @@ int sqlite3WinTempFileName(char *zBuf){ /* ** Close a file. +** +** It is reported that an attempt to close a handle might sometimes +** fail. This is a very unreasonable result, but windows is notorious +** for being unreasonable so I do not doubt that it might happen. If +** the close fails, we pause for 100 milliseconds and try again. As +** many as MX_CLOSE_ATTEMPT attempts to close the handle are made before +** giving up and returning an error. */ +#define MX_CLOSE_ATTEMPT 3 static int winClose(OsFile **pId){ winFile *pFile; int rc = 1; @@ -817,7 +841,7 @@ static int winClose(OsFile **pId){ TRACE2("CLOSE %d\n", pFile->h); do{ rc = CloseHandle(pFile->h); - }while( rc==0 && cnt++ < 3 && (Sleep(100), 1) ); + }while( rc==0 && cnt++ < MX_CLOSE_ATTEMPT && (Sleep(100), 1) ); #if OS_WINCE winceDestroyLock(pFile); if( pFile->zDeleteOnClose ){