aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordan <dan@noemail.net>2010-08-10 07:12:26 +0000
committerdan <dan@noemail.net>2010-08-10 07:12:26 +0000
commit84612fec1c94840c7175a4aa03ffac5505960467 (patch)
treee06f371c95257313d8f7226501701478e5e657a6
parent9b8d02727a1b1a613d89528a5f062f5ceaf8d534 (diff)
downloadsqlite-84612fec1c94840c7175a4aa03ffac5505960467.tar.gz
sqlite-84612fec1c94840c7175a4aa03ffac5505960467.zip
Changes to debugging code in mutex_unix.c and mutex_w32.c to make an assert() statement threadsafe.
FossilOrigin-Name: e82e32bd431ccacd276df8241592eb5519d87122
-rw-r--r--manifest16
-rw-r--r--manifest.uuid2
-rw-r--r--src/mutex_unix.c2
-rw-r--r--src/mutex_w32.c4
4 files changed, 14 insertions, 10 deletions
diff --git a/manifest b/manifest
index 83511bb31..fc2177865 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\stypos\sin\scomments.\s\sNo\sfunctional\schanges\sto\sthe\scode.
-D 2010-08-09T15:44:21
+C Changes\sto\sdebugging\scode\sin\smutex_unix.c\sand\smutex_w32.c\sto\smake\san\sassert()\sstatement\sthreadsafe.
+D 2010-08-10T07:12:27
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -147,8 +147,8 @@ F src/mutex.c 6949180803ff05a7d0e2b9334a95b4fb5a00e23f
F src/mutex.h 6fde601e55fa6c3fae768783c439797ab84c87c6
F src/mutex_noop.c d5cfbca87168c661a0b118cd8e329a908e453151
F src/mutex_os2.c 6a62583e374ba3ac1a3fcc0da2bfdac7d3942689
-F src/mutex_unix.c cf84466b4fdd2baa0d5a10bb19f08b2abc1ce42e
-F src/mutex_w32.c 1fe0e735897be20e09dd6f53c3fb516c6b48c0eb
+F src/mutex_unix.c abb8c98a6c27c57280e71522d059e929c708d019
+F src/mutex_w32.c b7ed3366a1d44a62a17d4eaefdaa2e7c25f944c2
F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30
F src/os.c 60178f518c4d6c0dcb59f7292232281d7bea2dcf
F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9
@@ -841,7 +841,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 88bf9016277c133dfbf4f4b2be0c35c9fe9fabd6
-R c5c5f9fc6458acbfcc375160225b3808
-U drh
-Z 2830757563a35deecc4832f7a9731398
+P 9cebaf2dca6dc35e489537fe7c55474e1029a98e
+R da77b0ae4e15ab90a6a323c7de4ca438
+U dan
+Z ef5f61caa72edd66e82b2e19ff2bf16a
diff --git a/manifest.uuid b/manifest.uuid
index 2efccd667..97623ccde 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-9cebaf2dca6dc35e489537fe7c55474e1029a98e \ No newline at end of file
+e82e32bd431ccacd276df8241592eb5519d87122 \ No newline at end of file
diff --git a/src/mutex_unix.c b/src/mutex_unix.c
index a1ebc3b75..196975e71 100644
--- a/src/mutex_unix.c
+++ b/src/mutex_unix.c
@@ -235,6 +235,7 @@ static void pthreadMutexEnter(sqlite3_mutex *p){
*/
pthread_mutex_lock(&p->mutex);
#if SQLITE_MUTEX_NREF
+ assert( p->nRef>0 || p->owner==0 );
p->owner = pthread_self();
p->nRef++;
#endif
@@ -307,6 +308,7 @@ static void pthreadMutexLeave(sqlite3_mutex *p){
assert( pthreadMutexHeld(p) );
#if SQLITE_MUTEX_NREF
p->nRef--;
+ if( p->nRef==0 ) p->owner = 0;
#endif
assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );
diff --git a/src/mutex_w32.c b/src/mutex_w32.c
index 442a6b786..fba964a46 100644
--- a/src/mutex_w32.c
+++ b/src/mutex_w32.c
@@ -220,7 +220,7 @@ static sqlite3_mutex *winMutexAlloc(int iType){
*/
static void winMutexFree(sqlite3_mutex *p){
assert( p );
- assert( p->nRef==0 );
+ assert( p->nRef==0 && p->owner==0 );
assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE );
DeleteCriticalSection(&p->mutex);
sqlite3_free(p);
@@ -244,6 +244,7 @@ static void winMutexEnter(sqlite3_mutex *p){
#endif
EnterCriticalSection(&p->mutex);
#ifdef SQLITE_DEBUG
+ assert( p->nRef>0 || p->owner==0 );
p->owner = tid;
p->nRef++;
if( p->trace ){
@@ -297,6 +298,7 @@ static void winMutexLeave(sqlite3_mutex *p){
assert( p->nRef>0 );
assert( p->owner==tid );
p->nRef--;
+ if( p->nRef==0 ) p->owner = 0;
assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );
#endif
LeaveCriticalSection(&p->mutex);