diff options
author | drh <drh@noemail.net> | 2016-04-07 13:45:20 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-04-07 13:45:20 +0000 |
commit | f878e6e1a76d0416ffa9987a406bf362cddc4e0e (patch) | |
tree | a242c7dfce7ab6081d428a73c574821e7f9e96cf /src/os_unix.c | |
parent | 40dc357a01ae544643b53c58c92fe0393cc47299 (diff) | |
download | sqlite-f878e6e1a76d0416ffa9987a406bf362cddc4e0e.tar.gz sqlite-f878e6e1a76d0416ffa9987a406bf362cddc4e0e.zip |
Update comments on the unix file locking protocol. No changes to code.
FossilOrigin-Name: 716b20de4306de1653ba5bcdbfb8d210d2d46e1a
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 6d1bb0b46..a797541e8 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1502,7 +1502,7 @@ static int unixLock(sqlite3_file *id, int eFileLock){ ** lock transitions in terms of the POSIX advisory shared and exclusive ** lock primitives (called read-locks and write-locks below, to avoid ** confusion with SQLite lock names). The algorithms are complicated - ** slightly in order to be compatible with windows systems simultaneously + ** slightly in order to be compatible with Windows95 systems simultaneously ** accessing the same database file, in case that is ever required. ** ** Symbols defined in os.h indentify the 'pending byte' and the 'reserved @@ -1510,8 +1510,14 @@ static int unixLock(sqlite3_file *id, int eFileLock){ ** range', a range of 510 bytes at a well known offset. ** ** To obtain a SHARED lock, a read-lock is obtained on the 'pending - ** byte'. If this is successful, a random byte from the 'shared byte - ** range' is read-locked and the lock on the 'pending byte' released. + ** byte'. If this is successful, 'shared byte range' is read-locked + ** and the lock on the 'pending byte' released. (Legacy note: When + ** SQLite was first developed, Windows95 systems were still very common, + ** and Widnows95 lacks a shared-lock capability. So on Windows95, a + ** single randomly selected by from the 'shared byte range' is locked. + ** Windows95 is now pretty much extinct, but this work-around for the + ** lack of shared-locks on Windows95 lives on, for backwards + ** compatibility.) ** ** A process may only obtain a RESERVED lock after it has a SHARED lock. ** A RESERVED lock is implemented by grabbing a write-lock on the @@ -1530,11 +1536,6 @@ static int unixLock(sqlite3_file *id, int eFileLock){ ** 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. - ** - ** The reason a single byte cannot be used instead of the 'shared byte - ** range' is that some versions of windows do not support read-locks. By - ** locking a random byte from a range, concurrent SHARED locks may exist - ** even if the locking primitive used is always a write-lock. */ int rc = SQLITE_OK; unixFile *pFile = (unixFile*)id; |