aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 45ba0c001..c94c0c111 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -2279,16 +2279,21 @@ static int nolockClose(sqlite3_file *id) {
/*
** This routine checks if there is a RESERVED lock held on the specified
-** file by this or any other process. The caller always holds a SHARED
-** lock when it is called. This means that no other connection could
-** hold a RESERVED lock, as unix-dotfile uses just a single exclusive lock -
-** the presence of the dotfile - for all 4 VFS locks. So this function sets
-** (*pResOut) to 0 (no other connection holds RESERVED) and returns SQLITE_OK.
+** file by this or any other process. If the caller holds a SHARED
+** or greater lock when it is called, then it is assumed that no other
+** client may hold RESERVED. Or, if the caller holds no lock, then it
+** is assumed another client holds RESERVED if the lock-file exists.
*/
static int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) {
+ unixFile *pFile = (unixFile*)id;
SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
- assert( ((unixFile*)id)->eFileLock>=SHARED_LOCK );
- *pResOut = 0;
+
+ if( pFile->eFileLock>=SHARED_LOCK ){
+ *pResOut = 0;
+ }else{
+ *pResOut = osAccess((const char*)pFile->lockingContext, 0)==0;
+ }
+ OSTRACE(("TEST WR-LOCK %d %d %d (dotlock)\n", pFile->h, 0, *pResOut));
return SQLITE_OK;
}