]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Attempt to reduce the amount of retry time when trying to open
authordrh <>
Wed, 26 Mar 2025 14:45:15 +0000 (14:45 +0000)
committerdrh <>
Wed, 26 Mar 2025 14:45:15 +0000 (14:45 +0000)
an inaccessible database file on Windows.  See
[forum:/forumpost/e7991420f54dca50|forum thread e7991420f5]

FossilOrigin-Name: 986e45912cde7cb8e6db8ba7a9364aef7187a23032be64ef6cd573163f56676d

manifest
manifest.uuid
src/os_win.c

index fd16d584a0abc1c971414a381b4c97e6c5811df7..9b2706403ee331f61f26a068f5da27406312442c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Configure\sscript\sinternal\scleanups.\sFactor\sout\sthe\ssuperfluous\sproj-lshift_\sand\suse\slassign\sinstead.\sAdd\s-ro\sflag\sto\sproj-file-write.
-D 2025-03-25T01:32:16.183
+C Attempt\sto\sreduce\sthe\samount\sof\sretry\stime\swhen\strying\sto\sopen\nan\sinaccessible\sdatabase\sfile\son\sWindows.\s\sSee\n[forum:/forumpost/e7991420f54dca50|forum\sthread\se7991420f5]
+D 2025-03-26T14:45:15.858
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d
@@ -770,7 +770,7 @@ F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e
 F src/os_kv.c 4d39e1f1c180b11162c6dc4aa8ad34053873a639bac6baae23272fc03349986a
 F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d872107
 F src/os_unix.c 410185df4900817c218c0efdb8064b3481af88cb3f7cea7392f820b6eebc7889
-F src/os_win.c ab9912a2c1cb39a6429b8de919a5b63ad1c7775e511d748391c57bf9ad03bd29
+F src/os_win.c 4101da78fb67baebff7fb4e763015b943aa3a1160d3a50e6b1932d77154d9fcb
 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
 F src/pager.c 9fbb541b46125dfa8914827575e6bb4d15048caa008073b1709112d495d7983b
 F src/pager.h 6137149346e6c8a3ddc1eeb40aee46381e9bc8b0fcc6dda8a1efde993c2275b8
@@ -2215,8 +2215,11 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 3c53abf5e6df446d569040042363265737aa10fc8aaa20b31c587100c557c5e7
-R 1bbb3c025ec1b46650981e453b29c862
-U stephan
-Z c139b7624e642b2a32a6648b4ac4392b
+P 1f98fc07fdf06d699ffbf1521b0b5e937a582017e4325bd994b488e06becbecc
+R 6f6ce59b3ff23057e3579b9943d2a4aa
+T *branch * winopen-retry
+T *sym-winopen-retry *
+T -sym-trunk *
+U drh
+Z ef0135aae199dad5cd806976ce43f48e
 # Remove this line to create a well-formed Fossil manifest.
index ce13eb13ea28afef70c4d7e783e991f7cbb52cba..382b9eb59e126585681233888a900c190266f871 100644 (file)
@@ -1 +1 @@
-1f98fc07fdf06d699ffbf1521b0b5e937a582017e4325bd994b488e06becbecc
+986e45912cde7cb8e6db8ba7a9364aef7187a23032be64ef6cd573163f56676d
index dab8af34c4419ef6e3cddc9dd8b2bacab8f61248..03bdc30d05bec276a1de9f6e5a2bbf9b8ef9618e 100644 (file)
@@ -5279,6 +5279,12 @@ static int winAccess(
   int *pResOut               /* OUT: Result */
 );
 
+/*
+** The Windows version of xAccess() accepts an extra bit in the flags
+** parameter that prevents an anti-virus retry loop.
+*/
+#define NORETRY 0x4000
+
 /*
 ** Open a file.
 */
@@ -5466,10 +5472,10 @@ static int winOpen(
                         dwCreationDisposition,
                         &extendedParameters);
       if( h!=INVALID_HANDLE_VALUE ) break;
-      if( isReadWrite ){
+      if( isReadWrite && cnt==0 ){
         int rc2, isRO = 0;
         sqlite3BeginBenignMalloc();
-        rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ, &isRO);
+        rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ|NORETRY, &isRO);
         sqlite3EndBenignMalloc();
         if( rc2==SQLITE_OK && isRO ) break;
       }
@@ -5483,10 +5489,10 @@ static int winOpen(
                         dwFlagsAndAttributes,
                         NULL);
       if( h!=INVALID_HANDLE_VALUE ) break;
-      if( isReadWrite ){
+      if( isReadWrite && cnt==0 ){
         int rc2, isRO = 0;
         sqlite3BeginBenignMalloc();
-        rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ, &isRO);
+        rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ|NORETRY, &isRO);
         sqlite3EndBenignMalloc();
         if( rc2==SQLITE_OK && isRO ) break;
       }
@@ -5503,10 +5509,10 @@ static int winOpen(
                         dwFlagsAndAttributes,
                         NULL);
       if( h!=INVALID_HANDLE_VALUE ) break;
-      if( isReadWrite ){
+      if( isReadWrite && cnt==0 ){
         int rc2, isRO = 0;
         sqlite3BeginBenignMalloc();
-        rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ, &isRO);
+        rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ|NORETRY, &isRO);
         sqlite3EndBenignMalloc();
         if( rc2==SQLITE_OK && isRO ) break;
       }
@@ -5723,8 +5729,14 @@ static int winAccess(
   int rc = 0;
   DWORD lastErrno = 0;
   void *zConverted;
+  int noRetry = 0;           /* Do not use winRetryIoerr() */
   UNUSED_PARAMETER(pVfs);
 
+  if( (flags & NORETRY)!=0 ){
+    noRetry = 1;
+    flags &= ~NORETRY;
+  }  
+
   SimulateIOError( return SQLITE_IOERR_ACCESS; );
   OSTRACE(("ACCESS name=%s, flags=%x, pResOut=%p\n",
            zFilename, flags, pResOut));
@@ -5747,7 +5759,10 @@ static int winAccess(
     memset(&sAttrData, 0, sizeof(sAttrData));
     while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted,
                              GetFileExInfoStandard,
-                             &sAttrData)) && winRetryIoerr(&cnt, &lastErrno) ){}
+                             &sAttrData))
+       && !noRetry
+       && winRetryIoerr(&cnt, &lastErrno)
+    ){ /* Loop until true */}
     if( rc ){
       /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file
       ** as if it does not exist.