aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2017-11-08 19:26:27 +0000
committerdrh <drh@noemail.net>2017-11-08 19:26:27 +0000
commit9214c1efe831ca60df04f0a06bb6b1cfd5ca6d38 (patch)
tree5e2808bdb236383a6234f72cb23688bafe0174b9 /src
parent7316960cec0ea2b411946964f4c02538ff7e3e1c (diff)
downloadsqlite-9214c1efe831ca60df04f0a06bb6b1cfd5ca6d38.tar.gz
sqlite-9214c1efe831ca60df04f0a06bb6b1cfd5ca6d38.zip
Extra comments on the sqlite3OsShmMap() call in walBeginUnlocked(). No
changes to code. FossilOrigin-Name: 033ee92bf4d5dc57f5cb8fd02d1154ae06f2d3261d214e7191a82c70c8ffebf7
Diffstat (limited to 'src')
-rw-r--r--src/wal.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/wal.c b/src/wal.c
index 11cdeb844..afd0e3f7b 100644
--- a/src/wal.c
+++ b/src/wal.c
@@ -2210,6 +2210,14 @@ static int walBeginUnlocked(Wal *pWal, int *pChanged){
/* Try to map the *-shm file again. If it succeeds this time, then
** a non-readonly_shm connection has already connected to the database.
** In this case, start over with opening the transaction.
+ **
+ ** The *-shm file was opened read-only, so sqlite3OsShmMap() can never
+ ** return SQLITE_OK here, as that would imply that it had established
+ ** a read/write mapping. A return of SQLITE_READONLY means success - that
+ ** a mapping has been established to a shared-memory segment that is actively
+ ** maintained by a writer. SQLITE_READONLY_CANTINIT means that all
+ ** all connections to the -shm file are read-only and hence the content
+ ** of the -shm file might be out-of-date.
**
** The WAL_READ_LOCK(0) lock held by this client prevents a checkpoint
** from taking place. But it does not prevent the wal from being wrapped
@@ -2219,8 +2227,8 @@ static int walBeginUnlocked(Wal *pWal, int *pChanged){
** the unlocked transaction, as the other client may overwrite wal
** frames that this client is still using. */
rc = sqlite3OsShmMap(pWal->pDbFd, 0, WALINDEX_PGSZ, 0, &pDummy);
+ assert( rc!=SQLITE_OK ); /* SQLITE_OK not possible for read-only connection */
if( rc!=SQLITE_READONLY_CANTINIT ){
- assert( rc!=SQLITE_OK );
rc = (rc==SQLITE_READONLY ? WAL_RETRY : rc);
goto begin_unlocked_out;
}