diff options
author | drh <drh@noemail.net> | 2015-02-21 15:13:50 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2015-02-21 15:13:50 +0000 |
commit | 878acb32efa879e0b680cce08f63e65f89fa4f77 (patch) | |
tree | 84f334c6f75c248e10f9a92c17e3dae631f2c597 /src/mutex_unix.c | |
parent | 1ee4a2dd88663517c8dd980926af9e76f37c88fb (diff) | |
parent | 2da47d38691b74a6cfa2ce2e5bdce3bb7d8fc186 (diff) | |
download | sqlite-878acb32efa879e0b680cce08f63e65f89fa4f77.tar.gz sqlite-878acb32efa879e0b680cce08f63e65f89fa4f77.zip |
Merge all recent trunk changes into the sessions branch.
FossilOrigin-Name: f36bb5fa5c5e3430808fe35d58f45559a216d341
Diffstat (limited to 'src/mutex_unix.c')
-rw-r--r-- | src/mutex_unix.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/mutex_unix.c b/src/mutex_unix.c index c936914d8..e08448e02 100644 --- a/src/mutex_unix.c +++ b/src/mutex_unix.c @@ -40,8 +40,10 @@ */ struct sqlite3_mutex { pthread_mutex_t mutex; /* Mutex controlling the lock */ -#if SQLITE_MUTEX_NREF +#if SQLITE_MUTEX_NREF || defined(SQLITE_ENABLE_API_ARMOR) int id; /* Mutex type */ +#endif +#if SQLITE_MUTEX_NREF volatile int nRef; /* Number of entrances */ volatile pthread_t owner; /* Thread that is within this mutex */ int trace; /* True to trace changes */ @@ -158,18 +160,12 @@ static sqlite3_mutex *pthreadMutexAlloc(int iType){ pthread_mutex_init(&p->mutex, &recursiveAttr); pthread_mutexattr_destroy(&recursiveAttr); #endif -#if SQLITE_MUTEX_NREF - p->id = iType; -#endif } break; } case SQLITE_MUTEX_FAST: { p = sqlite3MallocZero( sizeof(*p) ); if( p ){ -#if SQLITE_MUTEX_NREF - p->id = iType; -#endif pthread_mutex_init(&p->mutex, 0); } break; @@ -182,12 +178,12 @@ static sqlite3_mutex *pthreadMutexAlloc(int iType){ } #endif p = &staticMutexes[iType-2]; -#if SQLITE_MUTEX_NREF - p->id = iType; -#endif break; } } +#if SQLITE_MUTEX_NREF || defined(SQLITE_ENABLE_API_ARMOR) + if( p ) p->id = iType; +#endif return p; } @@ -199,9 +195,18 @@ static sqlite3_mutex *pthreadMutexAlloc(int iType){ */ static void pthreadMutexFree(sqlite3_mutex *p){ assert( p->nRef==0 ); - assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ); - pthread_mutex_destroy(&p->mutex); - sqlite3_free(p); +#if SQLITE_ENABLE_API_ARMOR + if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ) +#endif + { + pthread_mutex_destroy(&p->mutex); + sqlite3_free(p); + } +#ifdef SQLITE_ENABLE_API_ARMOR + else{ + (void)SQLITE_MISUSE_BKPT; + } +#endif } /* |