Index: src/loadext.c ================================================================== --- src/loadext.c +++ src/loadext.c @@ -370,11 +370,11 @@ ** loaded by every new database connection. */ int sqlite3_auto_extension(void *xInit){ int i; int rc = SQLITE_OK; - sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_GLOBAL); + sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); sqlite3_mutex_enter(mutex); for(i=0; i=nAutoExtension ){ xInit = 0; go = 0; }else{ Index: src/os_unix.c ================================================================== --- src/os_unix.c +++ src/os_unix.c @@ -371,14 +371,14 @@ /* ** Helper functions to obtain and relinquish the global mutex. */ static void enterMutex(){ - sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_GLOBAL)); + sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER)); } static void leaveMutex(){ - sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_GLOBAL)); + sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER)); } #if SQLITE_THREADSAFE /* ** This variable records whether or not threads can override each others Index: src/random.c ================================================================== --- src/random.c +++ src/random.c @@ -13,11 +13,11 @@ ** generator (PRNG) for SQLite. ** ** Random numbers are used by some of the database backends in order ** to generate random integer keys for tables or random filenames. ** -** $Id: random.c,v 1.19 2007/08/21 10:44:16 drh Exp $ +** $Id: random.c,v 1.20 2007/08/21 13:51:23 drh Exp $ */ #include "sqliteInt.h" /* @@ -89,11 +89,15 @@ /* ** Return N random bytes. */ void sqlite3Randomness(int N, void *pBuf){ unsigned char *zBuf = pBuf; - sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_PRNG)); + static sqlite3_mutex *mutex = 0; + if( mutex==0 ){ + mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PRNG); + } + sqlite3_mutex_enter(mutex); while( N-- ){ *(zBuf++) = randomByte(); } - sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_PRNG)); + sqlite3_mutex_leave(mutex); } Index: src/sqliteInt.h ================================================================== --- src/sqliteInt.h +++ src/sqliteInt.h @@ -9,11 +9,11 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.593 2007/08/20 22:48:43 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.594 2007/08/21 13:51:23 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ #include "sqliteLimit.h" @@ -191,20 +191,10 @@ typedef UINT16_TYPE u16; /* 2-byte unsigned integer */ typedef INT16_TYPE i16; /* 2-byte signed integer */ typedef UINT8_TYPE u8; /* 1-byte unsigned integer */ typedef UINT8_TYPE i8; /* 1-byte signed integer */ -/* -** The mutex subsystem provides a handfull of static mutexes -** that are identified by small positive integers. The following -** macros give symbolic names to those integers. -*/ -#define SQLITE_MUTEX_MEM 1 /* Used by the memory allocator */ -#define SQLITE_MUTEX_PRNG 2 /* Used by pseudorandom generator */ -#define SQLITE_MUTEX_GLOBAL 3 /* Used by global variables */ -#define SQLITE_MUTEX_STATIC_MAX 3 - /* ** Macros to determine whether the machine is big or little endian, ** evaluated at runtime. */ extern const int sqlite3one;