diff options
author | dan <Dan Kennedy> | 2023-11-27 19:22:50 +0000 |
---|---|---|
committer | dan <Dan Kennedy> | 2023-11-27 19:22:50 +0000 |
commit | e52854a9e6d3afacf60a690c1d31dc256da8cf1f (patch) | |
tree | ba9a5b649abbeb07adf0f5be828e3b768bfd1471 /src/os_unix.c | |
parent | 48cca2422eaff80968966c29705222be8b061d72 (diff) | |
download | sqlite-e52854a9e6d3afacf60a690c1d31dc256da8cf1f.tar.gz sqlite-e52854a9e6d3afacf60a690c1d31dc256da8cf1f.zip |
In SQLITE_ENABLE_SETLK_TIMEOUT builds, use blocking locks in place of sleep() when opening a read-transaction.
FossilOrigin-Name: a51ef39998e25e86bd0600e71d15011b12e05f4319608018293bdaecb09e8c97
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 |