-C Another\sfix\sto\s[e33da6d5dc964db8]:\sEnsure\sthat\sthe\sEXISTS-to-JOIN\sbreak\nhappens\seven\sif\sthe\sinner\sloop\sis\sa\s"no-op"\sloop\sthat\snever\sexecutes\smore\nthan\sonce\sbecause\sit\sis\scontrolled\sby\sa\sUNIQUE\sindex.\s\sThis\sresolves\sthe\nerror\sreported\sin\s[forum:/forumpost/7992838ba2|forum\spost\s7992838ba2].\nTest\scases\sare\sin\sTH3.
-D 2025-12-05T01:33:23.992
+C Enhance\sthe\sunixIsSharingShmNode()\scode\s(check-in\s[6385a1962c69c69c])\nso\sthat\sit\smore\sunderstandable\sby\shumans,\sand\sso\sthat\sit\sdoes\snot\strigger\nfalse\spositive\sdeadlock\swarnings\sin\sTSAN.
+D 2025-12-05T12:22:23.299
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06
F src/os_kv.c fb7ba8d6204197357f1eb7e1c7450d09c10043bf7e99aba602f4aa46b8fb11a3
F src/os_setup.h 8efc64eda6a6c2f221387eefc2e7e45fd5a3d5c8337a7a83519ba4fbd2957ae2
-F src/os_unix.c 7945ede1e85b2d1b910e1b4af9ba342e964b1e30e79f4176480a60736445cb36
+F src/os_unix.c dcf7988ddbdd68619b821c9a722f9377abb46f1d26c9279eb5a50402fd43d749
F src/os_win.c a89b501fc195085c7d6c9eec7f5bd782625e94bb2a96b000f4d009703df1083f
F src/os_win.h 4c247cdb6d407c75186c94a1e84d5a22cbae4adcec93fcae8d2bc1f956fd1f19
F src/pager.c a81461de271ac4886ad75b7ca2cca8157a48635820c4646cd2714acdc2c17e5f
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 8dce36698949f2e3a9948afc7c2b6c06f575d12033148e8c55fa79c03a73e2b4
-R 2440a17c53adf3cd06510dbc8328e330
+P bbded6477020af4d52253c5af2d33ec9b9cd619d33f744206f7420458bd84f12
+R c1b0adad487f17c68c10bd2c579d8273
U drh
-Z c606aa1c85654749574896aa57a1c98a
+Z 7b2c53fc363a306bca11886e7b272b7d
# Remove this line to create a well-formed Fossil manifest.
pInode->nLock++;
pInode->nShared = 1;
}
- }else if( (eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1)
- || unixIsSharingShmNode(pFile)
- ){
+ }else if( eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1 ){
/* We are trying for an exclusive lock but another thread in this
** same process is still holding a shared lock. */
rc = SQLITE_BUSY;
+ }else if( unixIsSharingShmNode(pFile) ){
+ /* We are in WAL mode and attempting to delete the SHM and WAL
+ ** files due to closing the connection or changing out of WAL mode,
+ ** but another process still holds locks on the SHM file, thus
+ ** indicating that database locks have been broken, perhaps due
+ ** to a rogue close(open(dbFile)) or similar.
+ */
+ rc = SQLITE_BUSY;
}else{
/* The request was for a RESERVED or EXCLUSIVE lock. It is
** assumed that there is a SHARED or greater lock on the file
** still not a disaster.
*/
static int unixIsSharingShmNode(unixFile *pFile){
- int rc;
unixShmNode *pShmNode;
+ struct flock lock;
if( pFile->pShm==0 ) return 0;
if( pFile->ctrlFlags & UNIXFILE_EXCL ) return 0;
pShmNode = pFile->pShm->pShmNode;
- rc = 1;
- unixEnterMutex();
- if( ALWAYS(pShmNode->nRef==1) ){
- struct flock lock;
- lock.l_whence = SEEK_SET;
- lock.l_start = UNIX_SHM_DMS;
- lock.l_len = 1;
- lock.l_type = F_WRLCK;
- osFcntl(pShmNode->hShm, F_GETLK, &lock);
- if( lock.l_type==F_UNLCK ){
- rc = 0;
- }
- }
- unixLeaveMutex();
- return rc;
+#if SQLITE_ATOMIC_INTRINSICS
+ assert( AtomicLoad(&pShmNode->nRef)==1 );
+#endif
+ memset(&lock, 0, sizeof(lock));
+ lock.l_whence = SEEK_SET;
+ lock.l_start = UNIX_SHM_DMS;
+ lock.l_len = 1;
+ lock.l_type = F_WRLCK;
+ osFcntl(pShmNode->hShm, F_GETLK, &lock);
+ return (lock.l_type!=F_UNLCK);
}
/*