pub struct FileLock { /* private fields */ }Expand description
An exclusive advisory lock over one file, held for as long as the value
lives and released when it drops, including on an early ? and by the
kernel if the process dies holding it.
The lock is on a sibling <name>.lock, never on the guarded file
itself, and that is the whole design decision: a store finishes its
write by renameing a new file over the old one, which replaces the
inode. A lock on the store would guard an inode the next successful
write unlinks, and the writer after that would open the new inode, find
it unlocked, and exclude nothing. The lock file is never renamed,
rewritten or read; it is an inode with a stable identity, left on disk
between writes so every writer keeps agreeing on which one it is.
Two are held at once only over shep.toml and dogs.toml, in that
order, which is what keeps the callers that nest them from deadlocking;
commands::dog_migration says so where it nests them.
Derives Debug: the fields are a held OS lock handle (a flock(2)
wrapper on unix, a bare File on Windows), never a secret.