diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/loadext.c | 6 | ||||
-rw-r--r-- | src/os_unix.c | 4 | ||||
-rw-r--r-- | src/random.c | 10 | ||||
-rw-r--r-- | src/sqliteInt.h | 12 |
4 files changed, 13 insertions, 19 deletions
diff --git a/src/loadext.c b/src/loadext.c index f2d93907f..5e854e933 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -372,7 +372,7 @@ static void **aAutoExtension = 0; 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; i++){ if( aAutoExtension[i]==xInit ) break; @@ -396,7 +396,7 @@ int sqlite3_auto_extension(void *xInit){ ** Reset the automatic extension loading mechanism. */ void sqlite3_reset_auto_extension(void){ - sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_GLOBAL); + sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); sqlite3_mutex_enter(mutex); sqlite3_free(aAutoExtension); aAutoExtension = 0; @@ -419,7 +419,7 @@ int sqlite3AutoLoadExtensions(sqlite3 *db){ } for(i=0; go; i++){ char *zErrmsg = 0; - sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_GLOBAL); + sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); sqlite3_mutex_enter(mutex); if( i>=nAutoExtension ){ xInit = 0; diff --git a/src/os_unix.c b/src/os_unix.c index a268f28bc..066ae6e58 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -373,10 +373,10 @@ typedef enum { ** 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 diff --git a/src/random.c b/src/random.c index 6443a01e0..19b284f94 100644 --- a/src/random.c +++ b/src/random.c @@ -15,7 +15,7 @@ ** 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" @@ -91,9 +91,13 @@ static int randomByte(void){ */ 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); } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 63bb6a3d9..d388afffd 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** 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_ @@ -194,16 +194,6 @@ 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. */ |