1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Fix an inconsistent #ifdef in wal.c. Fix os_unix.c so that it does not allow

moving an SHM lock directly exclusive to shared without going through unlocked.

FossilOrigin-Name: 552658da2845c2323167b6c7db6e5c00090f280c
This commit is contained in:
drh
2010-05-31 16:56:14 +00:00
parent d0aa34277f
commit 15d6809222
4 changed files with 26 additions and 15 deletions

View File

@@ -3569,6 +3569,11 @@ static int unixShmRelease(sqlite3_file *fd){
/*
** Change the lock state for a shared-memory segment.
**
** Note that the relationship between SHAREd and EXCLUSIVE locks is a little
** different here than in posix. In xShmLock(), one can go from unlocked
** to shared and back or from unlocked to exclusive and back. But one may
** not go from shared to exclusive or from exclusive to shared.
*/
static int unixShmLock(
sqlite3_file *fd, /* Database file holding the shared memory */
@@ -3626,7 +3631,6 @@ static int unixShmLock(
** SQLITE_BUSY.
*/
for(pX=pShmNode->pFirst; pX; pX=pX->pNext){
if( pX==p ) continue;
if( (pX->exclMask & mask)!=0 ){
rc = SQLITE_BUSY;
break;
@@ -3652,7 +3656,6 @@ static int unixShmLock(
** lock. If any do, return SQLITE_BUSY right away.
*/
for(pX=pShmNode->pFirst; pX; pX=pX->pNext){
if( pX==p ) continue;
if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){
rc = SQLITE_BUSY;
break;
@@ -3665,7 +3668,7 @@ static int unixShmLock(
if( rc==SQLITE_OK ){
rc = unixShmSystemLock(pShmNode, F_WRLCK, ofst+UNIX_SHM_BASE, n);
if( rc==SQLITE_OK ){
p->sharedMask &= ~mask;
assert( (p->sharedMask & mask)==0 );
p->exclMask |= mask;
}
}