diff options
author | drh <> | 2023-05-07 03:23:32 +0000 |
---|---|---|
committer | drh <> | 2023-05-07 03:23:32 +0000 |
commit | 28f32bedd16b6bb3f90848d3ac3778231eebca34 (patch) | |
tree | 12d7e9bb27a8f5b6b0c569558a718aaaa56b809f /src/pager.c | |
parent | 4e73863fd4dd66d6a404a66c69e37e33292fa50e (diff) | |
download | sqlite-28f32bedd16b6bb3f90848d3ac3778231eebca34.tar.gz sqlite-28f32bedd16b6bb3f90848d3ac3778231eebca34.zip |
It turns out that pagerExclusiveLock() can be called with the lock state
already set to RESERVED if the SQLITE_FCNTL_PERSIST_WAL setting is set and
a specific sequence of multiple journal mode changes occur.
Enhance pagerExclusiveLock() to deal with this.
[forum:/forumpost/8130545bc6|Forum post 8130545bc6]
FossilOrigin-Name: 2bb8d977392f635515aa4a36f6f763a2e4858f7adc1120519e2e74c04a9749b5
Diffstat (limited to 'src/pager.c')
-rw-r--r-- | src/pager.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/pager.c b/src/pager.c index 063b793f7..44384de5c 100644 --- a/src/pager.c +++ b/src/pager.c @@ -7473,13 +7473,15 @@ int sqlite3PagerWalSupported(Pager *pPager){ */ static int pagerExclusiveLock(Pager *pPager){ int rc; /* Return code */ + u8 eOrigLock; /* Original lock */ - assert( pPager->eLock==SHARED_LOCK || pPager->eLock==EXCLUSIVE_LOCK ); + assert( pPager->eLock>=SHARED_LOCK ); + eOrigLock = pPager->eLock; rc = pagerLockDb(pPager, EXCLUSIVE_LOCK); if( rc!=SQLITE_OK ){ /* If the attempt to grab the exclusive lock failed, release the ** pending lock that may have been obtained instead. */ - pagerUnlockDb(pPager, SHARED_LOCK); + pagerUnlockDb(pPager, eOrigLock); } return rc; |