Add the xInMutex method to the os-layer switch for testing whether or not

mutexes are used correctly. (CVS 2851)

FossilOrigin-Name: a582b159595ff8d31c81e9b3044711d6590d3f0e
This commit is contained in:
drh 2006-01-02 20:00:12 +00:00
parent 35a5965a17
commit 88f474a938
5 changed files with 37 additions and 13 deletions

View File

@ -1,5 +1,5 @@
C Additional\stests\sfor\sdescending\sindices.\s\sComment\schanges.\s(CVS\s2850)
D 2006-01-02T18:24:40
C Add\sthe\sxInMutex\smethod\sto\sthe\sos-layer\sswitch\sfor\stesting\swhether\sor\snot\nmutexes\sare\sused\scorrectly.\s(CVS\s2851)
D 2006-01-02T20:00:13
F Makefile.in e3c6b3a38d734d41574c04f2fc90d18de2b87102
F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -51,13 +51,13 @@ F src/legacy.c 59757d857ab95fcbb0ac27692d3201e35f093dd7
F src/main.c c93f80d1fcaf3ed508d62a163819b10a730c2fb7
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
F src/os.c 7b4a002d9c9421580276db55d2329636a604e8ef
F src/os.h e941992043b127fdb1bd114f0b4319ae1c4562a7
F src/os.h cc99e1515696728ba64c77fffa781ebadea34619
F src/os_common.h d0b1f2f32926e9b6db7886a7f43008b596a9e926
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
F src/os_unix.c 6394d2fa3a8bfbceb227579b44b4b343b5b54a8f
F src/os_unix.c e4fbf1370e1a03875ebb3239316fa8eb8476258b
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
F src/os_win.c 9feb97f49b93d451f8ef7c5dd388e05a44647dc6
F src/os_win.c 7e2d09f81cb83709b9774ac6be80fa3cb08ac86d
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pager.c 681b4e39d581ead8fd54283176138bec924a4bae
F src/pager.h e0acb095b3ad0bca48f2ab00c87346665643f64f
@ -333,7 +333,7 @@ F www/tclsqlite.tcl ddcf912ea48695603c8ed7efb29f0812ef8d1b49
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P a4aa0911bccd0627cd6d926c5bdd2a4f4b8f6cc5
R c2bfcb4903f64a4a18ff50a2924cea57
P 2622c5242b0cba5bc19f190a7c209ab9ed8f57e0
R 9a09811315517f7461beef7a4469c2f0
U drh
Z 1c84688d70590b66b4c8fd7b5cde6cad
Z c6af3ad936269fab04fee23696f1a4d8

View File

@ -1 +1 @@
2622c5242b0cba5bc19f190a7c209ab9ed8f57e0
a582b159595ff8d31c81e9b3044711d6590d3f0e

View File

@ -217,12 +217,13 @@ extern struct sqlite3OsVtbl {
int (*xSyncDirectory)(const char*);
int (*xTempFileName)(char*);
int (*xRandomSeed)(char*);
int (*xSleep)(int ms);
int (*xCurrentTime)(double*);
int (*xRandomSeed)(char*);
int (*xSleep)(int ms);
int (*xCurrentTime)(double*);
void (*xEnterMutex)(void);
void (*xLeaveMutex)(void);
int (*xInMutex)(void);
void *(*xThreadSpecificData)(int);
void *(*xMalloc)(int);
@ -238,7 +239,7 @@ extern struct sqlite3OsVtbl {
** is intriniscally thread-safe.
**
** External get/set access is only provided to the routines identified
** by the hash-defined SQLITE_OS_ROUTINE symbols.
** by the following SQLITE_OS_ROUTINE symbols:
*/
#define SQLITE_OS_ROUTINE_OPENREADWRITE 1
#define SQLITE_OS_ROUTINE_OPENREADONLY 2

View File

@ -1586,6 +1586,16 @@ static void unixLeaveMutex(){
#endif
}
/*
** Return TRUE if we are currently within the mutex and FALSE if not.
** This routine is intended for sanity checking only. It is designed
** for use in an assert() to verify that the mutex is held or not held
** in certain routines.
*/
static int unixInMutex(){
return inMutex;
}
/*
** This function is called automatically when a thread exists to delete
** the threads SqliteTsd structure.
@ -1706,6 +1716,7 @@ struct sqlite3OsVtbl sqlite3Os = {
unixCurrentTime,
unixEnterMutex,
unixLeaveMutex,
unixInMutex,
unixThreadSpecificData,
genericMalloc,
genericRealloc,

View File

@ -990,6 +990,17 @@ static void winLeaveMutex(){
#endif
}
/*
** Return TRUE if we are currently within the mutex and FALSE if not.
** This routine is intended for sanity checking only. It is designed
** for use in an assert() to verify that the mutex is held or not held
** in certain routines.
*/
static int winInMutex(){
return inMutex;
}
/*
** The following variable, if set to a non-zero value, becomes the result
** returned from sqlite3OsCurrentTime(). This is used for testing.
@ -1062,6 +1073,7 @@ struct sqlite3OsVtbl sqlite3Os = {
winCurrentTime,
winEnterMutex,
winLeaveMutex,
winInMutex,
winThreadSpecificData,
genericMalloc,
genericRealloc,