diff options
author | drh <drh@noemail.net> | 2010-05-05 00:05:24 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2010-05-05 00:05:24 +0000 |
commit | 92d765237936efd26a4e39991052f43e4ad32c82 (patch) | |
tree | c960cb6a619aa62832a86af0664092d17fee5fef /src/mutex_noop.c | |
parent | 7721b23e0a310c95e84088dab89494622e42087c (diff) | |
download | sqlite-92d765237936efd26a4e39991052f43e4ad32c82.tar.gz sqlite-92d765237936efd26a4e39991052f43e4ad32c82.zip |
When the in single-threaded mode, the sqlite3_mutex_alloc() interface
still returns a non-NULL value. The mutex doesn't do anything, but it
tests non-NULL. This way, extensions (or VFSes) that use sqlite3_mutex_alloc()
can tell the difference between an OOM error and mutexes being disabled.
FossilOrigin-Name: 451fd175758983c335aab449fdc4cb838156c4cb
Diffstat (limited to 'src/mutex_noop.c')
-rw-r--r-- | src/mutex_noop.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/mutex_noop.c b/src/mutex_noop.c index ee74da196..4df0a0600 100644 --- a/src/mutex_noop.c +++ b/src/mutex_noop.c @@ -28,7 +28,7 @@ #include "sqliteInt.h" -#if defined(SQLITE_MUTEX_NOOP) && !defined(SQLITE_DEBUG) +#ifndef SQLITE_DEBUG /* ** Stub routines for all mutex methods. ** @@ -44,7 +44,7 @@ static void noopMutexEnter(sqlite3_mutex *p){ return; } static int noopMutexTry(sqlite3_mutex *p){ return SQLITE_OK; } static void noopMutexLeave(sqlite3_mutex *p){ return; } -sqlite3_mutex_methods *sqlite3DefaultMutex(void){ +sqlite3_mutex_methods *sqlite3NoopMutex(void){ static sqlite3_mutex_methods sMutex = { noopMutexInit, noopMutexEnd, @@ -60,9 +60,9 @@ sqlite3_mutex_methods *sqlite3DefaultMutex(void){ return &sMutex; } -#endif /* defined(SQLITE_MUTEX_NOOP) && !defined(SQLITE_DEBUG) */ +#endif /* !SQLITE_DEBUG */ -#if defined(SQLITE_MUTEX_NOOP) && defined(SQLITE_DEBUG) +#ifdef SQLITE_DEBUG /* ** In this implementation, error checking is provided for testing ** and debugging purposes. The mutexes still do not provide any @@ -165,7 +165,7 @@ static void debugMutexLeave(sqlite3_mutex *p){ assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p) ); } -sqlite3_mutex_methods *sqlite3DefaultMutex(void){ +sqlite3_mutex_methods *sqlite3NoopMutex(void){ static sqlite3_mutex_methods sMutex = { debugMutexInit, debugMutexEnd, @@ -181,4 +181,14 @@ sqlite3_mutex_methods *sqlite3DefaultMutex(void){ return &sMutex; } -#endif /* defined(SQLITE_MUTEX_NOOP) && defined(SQLITE_DEBUG) */ +#endif /* SQLITE_DEBUG */ + +/* +** If compiled with SQLITE_MUTEX_NOOP, then the no-op mutex implementation +** is used regardless of the run-time threadsafety setting. +*/ +#ifdef SQLITE_MUTEX_NOOP +sqlite3_mutex_methods *sqlite3DefaultMutex(void){ + return sqliteNoopMutex(); +} +#endif /* SQLITE_MUTEX_NOOP */ |