Convert the unix driver to use a recusive mutex. Similar changes to the

windows driver are pending. (CVS 2968)

FossilOrigin-Name: 8830bbbac8e0c9243956aac42dc9f86a0bd1fa07
This commit is contained in:
drh 2006-01-18 14:06:37 +00:00
parent 950f054cec
commit a3fad6f5f3
3 changed files with 32 additions and 15 deletions

View File

@ -1,5 +1,5 @@
C Handle\smalloc()\sfailures\sthat\soccur\sin\sopen16()\sand\serrmsg16().\s(CVS\s2967)
D 2006-01-18T05:51:58
C Convert\sthe\sunix\sdriver\sto\suse\sa\srecusive\smutex.\s\sSimilar\schanges\sto\sthe\nwindows\sdriver\sare\spending.\s(CVS\s2968)
D 2006-01-18T14:06:38
F Makefile.in ab3ffd8d469cef4477257169b82810030a6bb967
F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -55,7 +55,7 @@ F src/os.h 9debc3d3ca4cdafde222a0ea74a4c8415aef4f22
F src/os_common.h 95b29ca6f3e6636cb33c9219b3f91a96fa7224b1
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
F src/os_unix.c 5f1ce55c0264114219cb9ae8e95b8624376c4fcb
F src/os_unix.c 7c085f807922309006f00b5fd8963865b92ff939
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
F src/os_win.c b9cb6254698cd7c2587c27e65b78c585473c6ffa
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
@ -341,7 +341,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P 95c5903f368413019af83aa73263e0e9d1204b62
R 6a825d2cc0d8c1f698b4dde375d79ff9
U danielk1977
Z 11afff1c430074d91a3b87b617dd2674
P 86eab9e53db8d7fecc789fe3d8cd8d7be3196fed
R 79ed702da5352631a14fd5c72072c4b8
U drh
Z d577dbc25e956de86c8f9b79929b1f93

View File

@ -1 +1 @@
86eab9e53db8d7fecc789fe3d8cd8d7be3196fed
8830bbbac8e0c9243956aac42dc9f86a0bd1fa07

View File

@ -1667,7 +1667,9 @@ int sqlite3UnixSleep(int ms){
*/
static int inMutex = 0;
#ifdef SQLITE_UNIX_THREADS
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_t mutexOwner;
static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
#endif
/*
@ -1682,16 +1684,27 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
*/
void sqlite3UnixEnterMutex(){
#ifdef SQLITE_UNIX_THREADS
pthread_mutex_lock(&mutex);
pthread_mutex_lock(&mutex1);
if( inMutex==0 ){
pthread_mutex_lock(&mutex2);
mutexOwner = pthread_self();
}
pthread_mutex_unlock(&mutex1);
#endif
assert( !inMutex );
inMutex = 1;
inMutex++;
}
void sqlite3UnixLeaveMutex(){
assert( inMutex );
inMutex = 0;
assert( inMutex>0 );
#ifdef SQLITE_UNIX_THREADS
pthread_mutex_unlock(&mutex);
assert( pthread_equal(mutexOwner, pthread_self()) );
pthread_mutex_lock(&mutex1);
inMutex--;
if( inMutex==0 ){
pthread_mutex_unlock(&mutex2);
}
pthread_mutex_unlock(&mutex1);
#else
inMutex--;
#endif
}
@ -1699,7 +1712,11 @@ void sqlite3UnixLeaveMutex(){
** Return TRUE if we are currently within the mutex and FALSE if not.
*/
int sqlite3UnixInMutex(){
#ifdef SQLITE_UNIX_THREADS
return inMutex && pthread_equal(mutexOwner, pthread_self());
#else
return inMutex;
#endif
}
/*