diff options
author | dan <dan@noemail.net> | 2010-04-30 10:06:09 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2010-04-30 10:06:09 +0000 |
commit | e93808dde24b8b53b9b2f954f1bf8d2df956b36e (patch) | |
tree | 3a0937f22a87d691bf9f546f7ed243a7c017c004 /src | |
parent | 4c97b53425204533345bb58185157d2e6e3eded5 (diff) | |
download | sqlite-e93808dde24b8b53b9b2f954f1bf8d2df956b36e.tar.gz sqlite-e93808dde24b8b53b9b2f954f1bf8d2df956b36e.zip |
Add missing mutexes to unixShmClose().
FossilOrigin-Name: a4741cb54dd5e753d48fd05ac9dbe27ee4aa1ec0
Diffstat (limited to 'src')
-rw-r--r-- | src/os_unix.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 5962d6824..decf2efc8 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5046,7 +5046,6 @@ static int unixShmClose(sqlite3_shm *pSharedMem){ unixShm *p; /* The connection to be closed */ unixShmFile *pFile; /* The underlying shared-memory file */ unixShm **pp; /* For looping over sibling connections */ - int nRef; /* Number of connections to pFile */ if( pSharedMem==0 ) return SQLITE_OK; p = (struct unixShm*)pSharedMem; @@ -5056,13 +5055,10 @@ static int unixShmClose(sqlite3_shm *pSharedMem){ assert( p->exclMask==0 ); assert( p->sharedMask==0 ); - /* Remove connection p from the set of connections associated with pFile */ sqlite3_mutex_enter(pFile->mutex); for(pp=&pFile->pFirst; (*pp)!=p; pp = &(*pp)->pNext){} *pp = p->pNext; - pFile->nRef--; - nRef = pFile->nRef; /* Free the connection p */ sqlite3_free(p); @@ -5070,9 +5066,14 @@ static int unixShmClose(sqlite3_shm *pSharedMem){ /* If pFile->nRef has reached 0, then close the underlying ** shared-memory file, too */ - if( nRef==0 ){ + unixEnterMutex(); + assert( pFile->nRef>0 ); + pFile->nRef--; + if( pFile->nRef==0 ){ unixShmPurge(); } + unixLeaveMutex(); + return SQLITE_OK; } |