diff options
author | drh <drh@noemail.net> | 2006-01-02 20:00:12 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2006-01-02 20:00:12 +0000 |
commit | 88f474a9380d3a890d484497bc8a8beaf5877a93 (patch) | |
tree | 7ece269d157265ceaac315ffd08d7741f8ed56f5 /src | |
parent | 35a5965a17f6a74e7c61395b15b578a301204689 (diff) | |
download | sqlite-88f474a9380d3a890d484497bc8a8beaf5877a93.tar.gz sqlite-88f474a9380d3a890d484497bc8a8beaf5877a93.zip |
Add the xInMutex method to the os-layer switch for testing whether or not
mutexes are used correctly. (CVS 2851)
FossilOrigin-Name: a582b159595ff8d31c81e9b3044711d6590d3f0e
Diffstat (limited to 'src')
-rw-r--r-- | src/os.h | 9 | ||||
-rw-r--r-- | src/os_unix.c | 11 | ||||
-rw-r--r-- | src/os_win.c | 12 |
3 files changed, 28 insertions, 4 deletions
@@ -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 diff --git a/src/os_unix.c b/src/os_unix.c index ab0d2c7b6..de7f0729c 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1587,6 +1587,16 @@ static void unixLeaveMutex(){ } /* +** 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, diff --git a/src/os_win.c b/src/os_win.c index 5565beaa0..3ecacb9c8 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -991,6 +991,17 @@ static void winLeaveMutex(){ } /* +** 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, |