diff options
author | dan <Dan Kennedy> | 2023-02-01 14:17:25 +0000 |
---|---|---|
committer | dan <Dan Kennedy> | 2023-02-01 14:17:25 +0000 |
commit | 288409d7319625702da13ee0e8e955482d9b99e2 (patch) | |
tree | c3d525d74eb9cd7fd1e761b543ae412b33ab19a0 /src/os_unix.c | |
parent | 42097421618f45d6fd078929820e558b30aa3683 (diff) | |
download | sqlite-288409d7319625702da13ee0e8e955482d9b99e2.tar.gz sqlite-288409d7319625702da13ee0e8e955482d9b99e2.zip |
Fix a comment related to PENDING locks in os_unix.c. No code changes.
FossilOrigin-Name: 6b3546c871fe78a4e550e0144b48ac98325787cc8b192a9e7f5f2a2ffa57f76d
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 7c1acc816..099096818 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1651,8 +1651,8 @@ static int unixFileLock(unixFile *pFile, struct flock *pLock){ ** ** UNLOCKED -> SHARED ** SHARED -> RESERVED -** SHARED -> (PENDING) -> EXCLUSIVE -** RESERVED -> EXCLUSIVE +** SHARED -> EXCLUSIVE +** RESERVED -> (PENDING) -> EXCLUSIVE ** PENDING -> EXCLUSIVE ** ** This routine will only increase a lock. Use the sqlite3OsUnlock() @@ -1684,19 +1684,20 @@ static int unixLock(sqlite3_file *id, int eFileLock){ ** A RESERVED lock is implemented by grabbing a write-lock on the ** 'reserved byte'. ** - ** A process may only obtain a PENDING lock after it has obtained a - ** SHARED lock. A PENDING lock is implemented by obtaining a write-lock - ** on the 'pending byte'. This ensures that no new SHARED locks can be - ** obtained, but existing SHARED locks are allowed to persist. A process - ** does not have to obtain a RESERVED lock on the way to a PENDING lock. - ** This property is used by the algorithm for rolling back a journal file - ** after a crash. + ** An EXCLUSIVE lock may only be requested after either a SHARED or + ** RESERVED lock is held. An EXCLUSIVE lock is implemented by obtaining + ** a write-lock on the entire 'shared byte range'. Since all other locks + ** require a read-lock on one of the bytes within this range, this ensures + ** that no other locks are held on the database. ** - ** An EXCLUSIVE lock, obtained after a PENDING lock is held, is - ** implemented by obtaining a write-lock on the entire 'shared byte - ** range'. Since all other locks require a read-lock on one of the bytes - ** within this range, this ensures that no other locks are held on the - ** database. + ** If a process that holds a RESERVED lock requests an EXCLUSIVE, then + ** a PENDING lock is obtained first. A PENDING lock is implemented by + ** obtaining a write-lock on the 'pending byte'. This ensures that no new + ** SHARED locks can be obtained, but existing SHARED locks are allowed to + ** persist. If the call to this function fails to obtain the EXCLUSIVE + ** lock in this case, it holds the PENDING lock intead. The client may + ** then re-attempt the EXCLUSIVE lock later on, after existing SHARED + ** locks have cleared. */ int rc = SQLITE_OK; unixFile *pFile = (unixFile*)id; |