diff options
author | drh <drh@noemail.net> | 2010-05-31 16:56:14 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2010-05-31 16:56:14 +0000 |
commit | 15d6809222b8f4b2619b8c56452aad21cc180958 (patch) | |
tree | befac98303428cad481fd3c771b6739834f81ba4 /src/os_unix.c | |
parent | d0aa34277fdfe83d8dda08ec9fddf4511f8fe914 (diff) | |
download | sqlite-15d6809222b8f4b2619b8c56452aad21cc180958.tar.gz sqlite-15d6809222b8f4b2619b8c56452aad21cc180958.zip |
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
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 659e91f3b..91f641e05 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -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; } } |