mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-09 14:21:03 +03:00
Begin adding mutexes. Compiles without SQLITE_OMIT_SHARED_CACHE but we
get an assertion fault on the shared cache testing. (CVS 4239) FossilOrigin-Name: 4c1e9ffebe7c611a8b6a89153ae97ab9bca19ea3
This commit is contained in:
26
src/mutex.c
26
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.3 2007/08/16 19:40:17 drh Exp $
|
||||
** $Id: mutex.c,v 1.4 2007/08/17 01:14:38 drh Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -228,17 +228,19 @@ void sqlite3_mutex_enter(sqlite3_mutex *pMutex){
|
||||
pthread_mutex_lock(&p->mutex);
|
||||
}else{
|
||||
struct RMutex *p = (struct RMutex*)pMutex;
|
||||
pthread_mutex_lock(&p->auxMutex);
|
||||
if( p->nRef==0 ){
|
||||
p->nRef++;
|
||||
p->owner = pthread_self();
|
||||
pthread_mutex_lock(&p->mainMutex);
|
||||
pthread_mutex_unlock(&p->auxMutex);
|
||||
}else if( pthread_equal(p->owner, pthread_self()) ){
|
||||
p->nRef++;
|
||||
pthread_mutex_unlock(&p->auxMutex);
|
||||
}else{
|
||||
while( p->nRef ){
|
||||
while(1){
|
||||
pthread_mutex_lock(&p->auxMutex);
|
||||
if( p->nRef==0 ){
|
||||
p->nRef++;
|
||||
p->owner = pthread_self();
|
||||
pthread_mutex_lock(&p->mainMutex);
|
||||
pthread_mutex_unlock(&p->auxMutex);
|
||||
break;
|
||||
}else if( pthread_equal(p->owner, pthread_self()) ){
|
||||
p->nRef++;
|
||||
pthread_mutex_unlock(&p->auxMutex);
|
||||
break;
|
||||
}else{
|
||||
pthread_mutex_unlock(&p->auxMutex);
|
||||
pthread_mutex_lock(&p->mainMutex);
|
||||
pthread_mutex_unlock(&p->mainMutex);
|
||||
|
||||
Reference in New Issue
Block a user