diff options
author | dan <Dan Kennedy> | 2023-11-27 20:37:03 +0000 |
---|---|---|
committer | dan <Dan Kennedy> | 2023-11-27 20:37:03 +0000 |
commit | bae2d0f2ebfa7385890adae075e998e86252b59e (patch) | |
tree | bc10e21cd3afc38ca3f20d5e0101afabeb40fd7d /src/wal.c | |
parent | e52854a9e6d3afacf60a690c1d31dc256da8cf1f (diff) | |
download | sqlite-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.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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; } |