aboutsummaryrefslogtreecommitdiff
path: root/src/wal.c
diff options
context:
space:
mode:
authordan <Dan Kennedy>2023-11-27 20:37:03 +0000
committerdan <Dan Kennedy>2023-11-27 20:37:03 +0000
commitbae2d0f2ebfa7385890adae075e998e86252b59e (patch)
treebc10e21cd3afc38ca3f20d5e0101afabeb40fd7d /src/wal.c
parente52854a9e6d3afacf60a690c1d31dc256da8cf1f (diff)
downloadsqlite-bae2d0f2ebfa7385890adae075e998e86252b59e.tar.gz
sqlite-bae2d0f2ebfa7385890adae075e998e86252b59e.zip
Have SQLITE_ENABLE_SETLK_TIMEOUT builds block when locking a read-lock slot.
FossilOrigin-Name: f797baf47cf7859cfd8ce248f4f3087af4551a7040af990333426e5a7c269504
Diffstat (limited to 'src/wal.c')
-rw-r--r--src/wal.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/wal.c b/src/wal.c
index c610c14d0..a15114710 100644
--- a/src/wal.c
+++ b/src/wal.c
@@ -2959,6 +2959,9 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){
int i; /* Loop counter */
int rc = SQLITE_OK; /* Return code */
u32 mxFrame; /* Wal frame to lock to */
+#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
+ int nBlockTmout = 0;
+#endif
assert( pWal->readLock<0 ); /* Not currently locked */
@@ -2996,7 +2999,8 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){
** attempted read fails and (b) the shared lock taken on the DMS slot
** in os_unix.c. Both of these locks are attempted from within the
** call to walIndexReadHdr() below. */
- if( cnt>=10 && !useWal && walEnableBlockingMs(pWal, (nDelay+999)/1000) ){
+ nBlockTmout = (nDelay+998) / 1000;
+ if( !useWal && walEnableBlockingMs(pWal, nBlockTmout) ){
nDelay = 1;
}
#endif
@@ -3126,7 +3130,9 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){
return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTINIT;
}
+ (void)walEnableBlockingMs(pWal, nBlockTmout);
rc = walLockShared(pWal, WAL_READ_LOCK(mxI));
+ walDisableBlocking(pWal);
if( rc ){
return rc==SQLITE_BUSY ? WAL_RETRY : rc;
}