Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Exclusive ¶
Exclusive takes an exclusive lock on the file at path, creating it and its directory, and returns the function releasing it. It waits for the lock until ctx is done.
It is for the short sections that must not interleave with the same section run by another process or another goroutine: the lock is held by the open file description, which every call opens anew, so it excludes the goroutines of this process as it excludes the other processes. A lock held by the process, as a fcntl lock is, would let every goroutine of the daemon in at once.
A holder dying releases the lock with its descriptors, so a crash leaves nothing to clean up and nobody to wait for.
The file is never removed. Removing a lock file on release lets a waiter that opened it before the removal and a newcomer that creates it after both hold the lock, on two files of the same name.
Types ¶
This section is empty.