]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Improved mutex protection of the sqlite3_temp_directory and tempdir-mutex
authordrh <>
Fri, 2 Sep 2022 11:12:16 +0000 (11:12 +0000)
committerdrh <>
Fri, 2 Sep 2022 11:12:16 +0000 (11:12 +0000)
sqlite3_data_directory global variables.

FossilOrigin-Name: ebbe9634d6dde9e097f61fb98a79111e46de422b7bbbd9ed3af7b6f22aacf5ec

manifest
manifest.uuid
src/os_win.c
src/sqliteInt.h

index f63a1088ae3222d5131b66165abf1c24c9261822..4a5639fda23e4f4f0d8301ba2685ba60766586a1 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Experimental\schanges\sto\sput\ssqlite3_temp_directory\sbehind\sa\smutex.
-D 2022-09-02T00:36:16.247
+C Improved\smutex\sprotection\sof\sthe\ssqlite3_temp_directory\sand\nsqlite3_data_directory\sglobal\svariables.
+D 2022-09-02T11:12:16.831
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -573,7 +573,7 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63
 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85
 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
 F src/os_unix.c 102f7e5c5b59c18ea3dbc929dc3be8acb3afc0e0b6ad572e032335c9c27f44f1
-F src/os_win.c d9ebd8bfce17d8fe49a08a87804dfa644c8fb20e28bca817ab62350c6ee2d4a5
+F src/os_win.c d55025aeb5b36b5d92d7c09fe709edaf2be901420782540ba4adad86729636a0
 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
 F src/pager.c c60031c483960660853dfecf14c8e830503baab1f638ac997f0144f1bd3e1781
 F src/pager.h f82e9844166e1585f5786837ddc7709966138ced17f568c16af7ccf946c2baa3
@@ -593,7 +593,7 @@ F src/shell.c.in e7e7c2c69ae86c5ee9e8ad66227203d46ff6dce8700a1b1dababff01c71d33d
 F src/sqlite.h.in b9b7fd73239d94db20332bb6e504688001e5564b655e1318a4427a1caef4b99e
 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
 F src/sqlite3ext.h a988810c9b21c0dc36dc7a62735012339dc76fc7ab448fb0792721d30eacb69d
-F src/sqliteInt.h 9c46510e108e6a525918c8d2c618a4c4527c53bc0c78c866edf5ee3315646726
+F src/sqliteInt.h a46ea998c6fdc3390a414db276c7410d9322ce40a2562775ddf5d1082f820763
 F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657
 F src/status.c 160c445d7d28c984a0eae38c144f6419311ed3eace59b44ac6dafc20db4af749
 F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
@@ -1999,11 +1999,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 1c4157c71cd1e062a9c2c79787d17e34e340f28ce1e40573851dfe174f5da7d7
-R 76adaad53bd26cbe572b84e819c193a2
-T *branch * tempdir-mutex
-T *sym-tempdir-mutex *
-T -sym-trunk *
+P 5ee3515fbb88bf1ae5f8b507844f82dcc429380b6ebeab9b09b52b25ee60a60d
+R c72d5281577d5a05e206ee4555729db3
 U drh
-Z 159fcca8739ffc7d9b735c4f860ae553
+Z 7b1cb313ea01e869890e1646257d0d7e
 # Remove this line to create a well-formed Fossil manifest.
index 6ab0e1756cf54d964a2a5b382da352bd79f9d457..88932bc11f630e642c312c0141b18de67f24fe27 100644 (file)
@@ -1 +1 @@
-5ee3515fbb88bf1ae5f8b507844f82dcc429380b6ebeab9b09b52b25ee60a60d
\ No newline at end of file
+ebbe9634d6dde9e097f61fb98a79111e46de422b7bbbd9ed3af7b6f22aacf5ec
\ No newline at end of file
index 591f57ee5ca51287dbdb02fa23e2f0a5c70353ca..4191db6bb798eda374447b90dbfa4deda6976f4a 100644 (file)
@@ -5576,7 +5576,7 @@ static BOOL winIsVerbatimPathname(
 ** pathname into zOut[].  zOut[] will be at least pVfs->mxPathname
 ** bytes in size.
 */
-static int winFullPathname(
+static int winFullPathnameNoMutex(
   sqlite3_vfs *pVfs,            /* Pointer to vfs object */
   const char *zRelative,        /* Possibly relative input path */
   int nFull,                    /* Size of output buffer in bytes */
@@ -5600,7 +5600,6 @@ static int winFullPathname(
   SimulateIOError( return SQLITE_ERROR );
   UNUSED_PARAMETER(nFull);
   assert( nFull>=pVfs->mxPathname );
-  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
   if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
     /*
     ** NOTE: We are dealing with a relative path name and the data
@@ -5651,7 +5650,6 @@ static int winFullPathname(
       sqlite3_free(zOut);
     }
   }
-  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
   return SQLITE_OK;
 #endif
 
@@ -5659,7 +5657,6 @@ static int winFullPathname(
   SimulateIOError( return SQLITE_ERROR );
   /* WinCE has no concept of a relative pathname, or so I am told. */
   /* WinRT has no way to convert a relative path to an absolute one. */
-  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
   if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
     /*
     ** NOTE: We are dealing with a relative path name and the data
@@ -5672,7 +5669,6 @@ static int winFullPathname(
   }else{
     sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative);
   }
-  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
   return SQLITE_OK;
 #endif
 
@@ -5683,7 +5679,6 @@ static int winFullPathname(
   ** current working directory has been unlinked.
   */
   SimulateIOError( return SQLITE_ERROR );
-  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
   if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
     /*
     ** NOTE: We are dealing with a relative path name and the data
@@ -5693,7 +5688,6 @@ static int winFullPathname(
     */
     sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s",
                      sqlite3_data_directory, winGetDirSep(), zRelative);
-    sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
     return SQLITE_OK;
   }
   zConverted = winConvertFromUtf8Filename(zRelative);
@@ -5761,6 +5755,19 @@ static int winFullPathname(
   }
 #endif
 }
+static int winFullPathname(
+  sqlite3_vfs *pVfs,            /* Pointer to vfs object */
+  const char *zRelative,        /* Possibly relative input path */
+  int nFull,                    /* Size of output buffer in bytes */
+  char *zFull                   /* Output buffer */
+){
+  int rc;
+  sqlite3_mutex *pMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR);
+  sqlite3_mutex_enter(pMutex);
+  rc = winFullPathnameNoMutex(pVfs, zRelative, nFull, zFull);
+  sqlite3_mutex_leave(pMutex);
+  return rc;
+}
 
 #ifndef SQLITE_OMIT_LOAD_EXTENSION
 /*
index eef09e1f0eae9c90bb5ad5e0f43e078c24f0e3ca..aeb4cac439eb4836a0dc51ab40bb5c168de3b081 100644 (file)
 /*
 ** Reuse the STATIC_LRU for mutex access to sqlite3_temp_directory.
 */
-#define SQLITE_MUTEX_STATIC_TEMPDIR SQLITE_MUTEX_STATIC_LRU
+#define SQLITE_MUTEX_STATIC_TEMPDIR SQLITE_MUTEX_STATIC_VFS1
 
 /*
 ** Include the configuration header output by 'configure' if we're using the
@@ -4561,6 +4561,7 @@ int sqlite3IndexHasDuplicateRootPage(Index*);
 int sqlite3Init(sqlite3*, char**);
 int sqlite3InitCallback(void*, int, char**, char**);
 int sqlite3InitOne(sqlite3*, int, char**, u32);
+char *sqlite3TempDirectory(void);
 void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);
 #ifndef SQLITE_OMIT_VIRTUALTABLE
 Module *sqlite3PragmaVtabRegister(sqlite3*,const char *zName);