diff options
author | dan <Dan Kennedy> | 2023-11-28 17:12:42 +0000 |
---|---|---|
committer | dan <Dan Kennedy> | 2023-11-28 17:12:42 +0000 |
commit | 940b23bc3a7e2ddafd824b937f04869a30e1912f (patch) | |
tree | 002dd43cf8a3d80cc5e579734f51334ac61eeda2 /src/os_unix.c | |
parent | 48cca2422eaff80968966c29705222be8b061d72 (diff) | |
parent | b8950e0f45656a96c09d5721e564fa0b8ef8e79a (diff) | |
download | sqlite-940b23bc3a7e2ddafd824b937f04869a30e1912f.tar.gz sqlite-940b23bc3a7e2ddafd824b937f04869a30e1912f.zip |
In SQLITE_ENABLE_SETLK_TIMEOUT builds, use blocking locks in place of sleep() calls when opening a read-transaction.
FossilOrigin-Name: 4c055b7a6e4533e1e571773456226ca7038ce372df3eedbbbcd9a81e8652a6cf
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 13 |
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 |