]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
More comments on the unix locking code. Ticket #1672. (CVS 3075)
authordrh <drh@noemail.net>
Fri, 10 Feb 2006 13:11:32 +0000 (13:11 +0000)
committerdrh <drh@noemail.net>
Fri, 10 Feb 2006 13:11:32 +0000 (13:11 +0000)
FossilOrigin-Name: 4b6f5688843ebe39f6bd3e863666a44d486fbe0f

manifest
manifest.uuid
src/os_unix.c

index 658dd4a1045d24998db49295d27f44c78798abe4..5ee284ac5ac19dda3c1d4297a7914b0a65c94354 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\strivial\stests\sto\sincrease\scoverage\sof\ssqlite3_table_column_metadata().\s(CVS\s3074)
-D 2006-02-10T12:48:55
+C More\scomments\son\sthe\sunix\slocking\scode.\s\sTicket\s#1672.\s(CVS\s3075)
+D 2006-02-10T13:11:32
 F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b
 F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -55,7 +55,7 @@ F src/os.h 93035a0e3b9dd05cdd0aaef32ea28ca28e02fe78
 F src/os_common.h 108cd719c96a2b714b64e02aeabbd40684274e6a
 F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
 F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
-F src/os_unix.c 50e51ba8a78e4a26850d77b077f0d43a5036a76c
+F src/os_unix.c bd42a51385691dc4834c7e1eca614f7f7c2889da
 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
 F src/os_win.c c67a2c46d929cf54c8f80ec5e6079cf684a141a9
 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
@@ -352,7 +352,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 5ea87fbbe09279e70d3a22b8cd9994befffeac53
-R 3b98451b049db21424079cc84f31ce2e
-U danielk1977
-Z 588362bbc144f893055bec96e1b4e2a6
+P 424ce5ecd0aa9860afb73180e4d09987f3a9300a
+R e847d3d7d8d22728ba3f4d78b38cd20a
+U drh
+Z 206d0335c5f7ebb9928e90a31eabfd6a
index 57b46e91cd7cca5443d9505feba99c95e4e45d03..a2c1ee27c2baf8b178e19ee962c3b14ac35ab500 100644 (file)
@@ -1 +1 @@
-424ce5ecd0aa9860afb73180e4d09987f3a9300a
\ No newline at end of file
+4b6f5688843ebe39f6bd3e863666a44d486fbe0f
\ No newline at end of file
index 602c023861568fe13a7a646bd1c5d53933bbe92d..e33f0f7c525476bcad3537f07e20d36629353641 100644 (file)
@@ -1675,22 +1675,34 @@ int sqlite3UnixSleep(int ms){
 ** inMutex      the nesting depth of the recursive mutex.  The thread
 **              holding mutexMain can read this variable at any time.
 **              But is must hold mutexAux to change this variable.  Other
-**              threads must hold mutexAux to read the variable.
+**              threads must hold mutexAux to read the variable and can
+**              never write.
 **
 ** mutexOwner   The thread id of the thread holding mutexMain.  Same
 **              access rules as for inMutex.
 **
-** mutexOwnerValid   True if the value in mutexOwner is valid.  
+** mutexOwnerValid   True if the value in mutexOwner is valid.  The same
+**                   access rules apply as for inMutex.
 **
 ** mutexMain    The main mutex.  Hold this mutex in order to get exclusive
 **              access to SQLite data structures.
 **
 ** mutexAux     An auxiliary mutex needed to access variables defined above.
 **
+** Mutexes are always acquired in this order: mutexMain mutexAux.   It
+** is not necessary to acquire mutexMain in order to get mutexAux - just
+** do not attempt to acquire them in the reverse order: mutexAux mutexMain.
+** Either get the mutexes with mutexMain first or get mutexAux only.
+**
+** When running on a platform where the three variables inMutex, mutexOwner,
+** and mutexOwnerValid can be set atomically, the mutexAux is not required.
+** On many systems, all three are 32-bit integers and writing to a 32-bit
+** integer is atomic.  I think.  But there are no guarantees.  So it seems
+** safer to protect them using mutexAux.
 */
 static int inMutex = 0;
 #ifdef SQLITE_UNIX_THREADS
-static pthread_t mutexOwner;          /* Thread holding the mutex */
+static pthread_t mutexOwner;          /* Thread holding mutexMain */
 static int mutexOwnerValid = 0;       /* True if mutexOwner is valid */
 static pthread_mutex_t mutexMain = PTHREAD_MUTEX_INITIALIZER; /* The mutex */
 static pthread_mutex_t mutexAux = PTHREAD_MUTEX_INITIALIZER;  /* Aux mutex */