diff options
author | drh <drh@noemail.net> | 2007-08-25 16:31:29 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2007-08-25 16:31:29 +0000 |
commit | 4b6b4ab0d28fe68f58a548c2a89b00af5d586421 (patch) | |
tree | 45d1aed6b650cd02210d567b28f95fee5a8ab639 /src | |
parent | 8bacf9743f45796fe4924e02b643454643918fc2 (diff) | |
download | sqlite-4b6b4ab0d28fe68f58a548c2a89b00af5d586421.tar.gz sqlite-4b6b4ab0d28fe68f58a548c2a89b00af5d586421.zip |
Create a fresh pthread_mutexattr_t every time a recursive mutex is
allocated. Ticket #2588. (CVS 4300)
FossilOrigin-Name: 3d746343add3feb9d208302a00b419d71d6ba246
Diffstat (limited to 'src')
-rw-r--r-- | src/mutex.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/mutex.c b/src/mutex.c index d50095f75..73021f653 100644 --- a/src/mutex.c +++ b/src/mutex.c @@ -12,7 +12,7 @@ ** This file contains the C functions that implement mutexes for ** use by the SQLite core. ** -** $Id: mutex.c,v 1.12 2007/08/25 16:21:30 drh Exp $ +** $Id: mutex.c,v 1.13 2007/08/25 16:31:30 drh Exp $ */ /* ** If SQLITE_MUTEX_APPDEF is defined, then this whole module is @@ -289,22 +289,14 @@ sqlite3_mutex *sqlite3_mutex_alloc(int iType){ sqlite3_mutex *p; switch( iType ){ case SQLITE_MUTEX_RECURSIVE: { - static pthread_mutex_t initMutex = PTHREAD_MUTEX_INITIALIZER; - static int isInit = 0; - static pthread_mutexattr_t recursiveAttr; - if( !isInit ){ - pthread_mutex_lock(&initMutex); - if( !isInit ){ - pthread_mutexattr_init(&recursiveAttr); - pthread_mutexattr_settype(&recursiveAttr, PTHREAD_MUTEX_RECURSIVE); - } - isInit = 1; - pthread_mutex_unlock(&initMutex); - } p = sqlite3MallocZero( sizeof(*p) ); if( p ){ - p->id = iType; + pthread_mutexattr_t recursiveAttr; + pthread_mutexattr_init(&recursiveAttr); + pthread_mutexattr_settype(&recursiveAttr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&p->mutex, &recursiveAttr); + pthread_mutexattr_destroy(&recursiveAttr); + p->id = iType; } break; } |