aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <Dan Kennedy>2023-11-15 19:19:04 +0000
committerdan <Dan Kennedy>2023-11-15 19:19:04 +0000
commit91c8e65dd4bf17d21fbf8f7073565fe1a71c8948 (patch)
treebeaa93bbdff567e4f857adafa75a4170143883d8 /src
parent9eb7694d587b2a8b61c180e0369f10ac23a72973 (diff)
parent4ffaa7c5dedbc86b5736b139bc0465524ab3db51 (diff)
downloadsqlite-91c8e65dd4bf17d21fbf8f7073565fe1a71c8948.tar.gz
sqlite-91c8e65dd4bf17d21fbf8f7073565fe1a71c8948.zip
Changes so that if SQLITE_ENABLE_SETLK_TIMEOUT is defined as 2 instead of 1, all blocking locks are taken for a single millisecond and the default busy-handler invoked as normal.
FossilOrigin-Name: 79e24ec3dd40373bbb93792829b18d9ef40daf19d4606174e36c8e19e61a7529
Diffstat (limited to 'src')
-rw-r--r--src/os_unix.c8
-rw-r--r--src/wal.c5
2 files changed, 9 insertions, 4 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index cd3e0fc54..3171b41fd 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -4054,7 +4054,13 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
case SQLITE_FCNTL_LOCK_TIMEOUT: {
int iOld = pFile->iBusyTimeout;
+#if SQLITE_ENABLE_SETLK_TIMEOUT==1
pFile->iBusyTimeout = *(int*)pArg;
+#elif SQLITE_ENABLE_SETLK_TIMEOUT==2
+ pFile->iBusyTimeout = !!(*(int*)pArg);
+#else
+# error "SQLITE_ENABLE_SETLK_TIMEOUT must be set to 1 or 2"
+#endif
*(int*)pArg = iOld;
return SQLITE_OK;
}
@@ -4426,7 +4432,7 @@ static int unixShmSystemLock(
f.l_len = n;
res = osSetPosixAdvisoryLock(pShmNode->hShm, &f, pFile);
if( res==-1 ){
-#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
+#if defined(SQLITE_ENABLE_SETLK_TIMEOUT) && SQLITE_ENABLE_SETLK_TIMEOUT==1
rc = (pFile->iBusyTimeout ? SQLITE_BUSY_TIMEOUT : SQLITE_BUSY);
#else
rc = SQLITE_BUSY;
diff --git a/src/wal.c b/src/wal.c
index 655d78f59..d83f361d6 100644
--- a/src/wal.c
+++ b/src/wal.c
@@ -4204,10 +4204,9 @@ int sqlite3WalCheckpoint(
if( pWal->readOnly ) return SQLITE_READONLY;
WALTRACE(("WAL%p: checkpoint begins\n", pWal));
- /* Enable blocking locks, if possible. If blocking locks are successfully
- ** enabled, set xBusy2=0 so that the busy-handler is never invoked. */
+ /* Enable blocking locks, if possible. */
sqlite3WalDb(pWal, db);
- (void)walEnableBlocking(pWal);
+ if( xBusy2 ) (void)walEnableBlocking(pWal);
/* IMPLEMENTATION-OF: R-62028-47212 All calls obtain an exclusive
** "checkpoint" lock on the database file.