From: mistachkin Date: Sat, 12 Sep 2015 04:19:51 +0000 (+0000) Subject: Specifying an invalid mutex implementation (via SQLITE_CONFIG_MUTEX) should cause... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=acc8f7b24c9b59e774b7f6a8923ea772c246fb42;p=thirdparty%2Fsqlite.git Specifying an invalid mutex implementation (via SQLITE_CONFIG_MUTEX) should cause the default one to be used instead. FossilOrigin-Name: 1a97bc81ccfc88f2dd527dff16e9e395718675bc --- diff --git a/manifest b/manifest index a8b89334c7..64a1a935e7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Clarify\sthe\snew\smutex\simplementation\sreset\slogic\sin\ssqlite3_shutdown(). -D 2015-09-12T03:40:13.463 +C Specifying\san\sinvalid\smutex\simplementation\s(via\sSQLITE_CONFIG_MUTEX)\sshould\scause\sthe\sdefault\sone\sto\sbe\sused\sinstead. +D 2015-09-12T04:19:51.382 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in f85066ce844a28b671aaeeff320921cd0ce36239 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -314,7 +314,7 @@ F src/mem3.c 61c9d47b792908c532ca3a62b999cf21795c6534 F src/mem5.c 61eeb90134f9a5be6c2e68d8daae7628b25953fb F src/memjournal.c 3eb2c0b51adbd869cb6a44780323f05fa904dc85 F src/msvc.h d9ba56c6851227ab44b3f228a35f3f5772296495 -F src/mutex.c 58c1a764c37ba3c139cfb9cd8c7449eb7b4d68d9 +F src/mutex.c 87bd895b69359cf01d611fa72849237087151e21 F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85 F src/mutex_noop.c f03e26ba8258399da23b51234f6b6a97197c1900 F src/mutex_unix.c a72043f2560147d8e85fe48a6aef682896deb3a0 @@ -1386,7 +1386,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7562f1fbede70b19bbbb928e0a534203528b5b65 -R 3ac5767399d8383f18e381780f08b08c +P f9a034834e6c6e32ac350cf48bec981490e533ad +R bf73c19c36cb2ae09dd34d5e1c1598fa U mistachkin -Z fd5ef4befe69774364afb3ff74061ec0 +Z 7d9d0679bd87dd4450cebce4f9dd2531 diff --git a/manifest.uuid b/manifest.uuid index ce06497aec..042e59a421 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f9a034834e6c6e32ac350cf48bec981490e533ad \ No newline at end of file +1a97bc81ccfc88f2dd527dff16e9e395718675bc \ No newline at end of file diff --git a/src/mutex.c b/src/mutex.c index e95d137b4b..cb21e70c97 100644 --- a/src/mutex.c +++ b/src/mutex.c @@ -26,6 +26,32 @@ static SQLITE_WSD int mutexIsInit = 0; #ifndef SQLITE_MUTEX_OMIT +/* +** This structure is for use by sqlite3MutexInit() only. It represents an +** invalid mutex implementation (i.e. one where all the function pointers +** are null). +*/ +static const sqlite3_mutex_methods mutexNullMethods = { + 0, /* xMutexInit */ + 0, /* xMutexEnd */ + 0, /* xMutexAlloc */ + 0, /* xMutexFree */ + 0, /* xMutexEnter */ + 0, /* xMutexTry */ + 0, /* xMutexLeave */ + 0, /* xMutexHeld */ + 0 /* xMutexNotheld */ +}; + +/* +** Returns non-zero if the currently configured mutex implemention is +** invalid (i.e. all of its function pointers are null). +*/ +static int mutexIsInvalid(void){ + return memcmp(&sqlite3GlobalConfig.mutex, &mutexNullMethods, + sizeof(sqlite3_mutex_methods))==0; +} + /* ** Copies a mutex implementation. Both arguments must point to valid ** memory. @@ -51,7 +77,7 @@ static void mutexCopy( int sqlite3MutexInit(void){ int rc; if( sqlite3CompareAndSwap((void * volatile *)&sqlite3GlobalConfig.pMutex, - 0, &sqlite3GlobalConfig.mutex)==0 ){ + 0, &sqlite3GlobalConfig.mutex)==0 || mutexIsInvalid() ){ /* If the xMutexAlloc method has not been set, then the user did not ** install a mutex implementation via sqlite3_config() prior to ** sqlite3_initialize() being called. This block copies pointers to