Index: src/mutex.c ================================================================== --- src/mutex.c +++ src/mutex.c @@ -73,10 +73,11 @@ /* ** Initialize the mutex system. */ int sqlite3MutexInit(void){ + static int initPending = 0; int rc; if( sqlite3CompareAndSwap((void * volatile *)&sqlite3GlobalConfig.pMutex, 0, &sqlite3GlobalConfig.mutex)==0 || mutexIsInvalid() ){ /* If the mutex implementation pointer has not been set, then the user ** did not install a mutex implementation via sqlite3_config() prior to @@ -91,12 +92,16 @@ pFrom = sqlite3NoopMutex(); } mutexCopy(&sqlite3GlobalConfig.mutex, pFrom); sqlite3MemoryBarrier(); } - assert( sqlite3GlobalConfig.mutex.xMutexInit ); - rc = sqlite3GlobalConfig.mutex.xMutexInit(); + if( !initPending ){ + assert( sqlite3GlobalConfig.mutex.xMutexInit ); + initPending = 1; + rc = sqlite3GlobalConfig.mutex.xMutexInit(); + initPending = 0; + } #ifdef SQLITE_DEBUG GLOBAL(int, mutexIsInit) = 1; #endif