aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordrh <>2023-11-29 12:18:02 +0000
committerdrh <>2023-11-29 12:18:02 +0000
commit6d7afd8ba839792c9f37982bc909ffa88b3fa347 (patch)
tree2716c7044e01ae3dac553310fded89123f26e647 /src/os_unix.c
parent4b54d6cdafacfab6f84f4fd2055739d69e34a954 (diff)
parent2ba5534101c28d1edcc1f1c6e70a2bfb193b818b (diff)
downloadsqlite-6d7afd8ba839792c9f37982bc909ffa88b3fa347.tar.gz
sqlite-6d7afd8ba839792c9f37982bc909ffa88b3fa347.zip
Merge all the latest trunk enhancements into the jsonb branch.
FossilOrigin-Name: 1a59fcab2179cc3b52ecd3de7d2018db96ac149aaff521959773a517b8d9ac3e
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index dab03c97f..7362a1320 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -4595,7 +4595,20 @@ static int unixLockSharedMemory(unixFile *pDbFd, unixShmNode *pShmNode){
pShmNode->isUnlocked = 1;
rc = SQLITE_READONLY_CANTINIT;
}else{
+#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
+ /* Do not use a blocking lock here. If the lock cannot be obtained
+ ** immediately, it means some other connection is truncating the
+ ** *-shm file. And after it has done so, it will not release its
+ ** lock, but only downgrade it to a shared lock. So no point in
+ ** blocking here. The call below to obtain the shared DMS lock may
+ ** use a blocking lock. */
+ int iSaveTimeout = pDbFd->iBusyTimeout;
+ pDbFd->iBusyTimeout = 0;
+#endif
rc = unixShmSystemLock(pDbFd, F_WRLCK, UNIX_SHM_DMS, 1);
+#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
+ pDbFd->iBusyTimeout = iSaveTimeout;
+#endif
/* The first connection to attach must truncate the -shm file. We
** truncate to 3 bytes (an arbitrary small number, less than the
** -shm header size) rather than 0 as a system debugging aid, to