Skip to main content

Module store_lock

Module store_lock 

Source
Expand description

Store locking for clink invocations (issue #194).

Every invocation loads the whole store, changes it in memory and saves it back. Two invocations that overlap would each save their own copy, and the later save would drop the writes of the earlier one. A StoreLock makes that read-modify-write exclusive: writers take it exclusively, readers share it, and a waiter gives up with a “store is locked” error naming the owner once --lock-timeout passes.

--lockLockReleased by
flockflock/LockFileEx on <db>.lockthe operating system when the holder exits
pidthe directory <db>.lock.dthe holder; a waiter breaks it when the owner process is gone
nonenothing-

An exclusive flock holder writes its owner record to <db>.lock.owner and removes it on release, so that waiters and --lock-status can name it. The record is a file of its own because on Windows the lock keeps every other process from reading <db>.lock itself.

Structs§

LockOwner
Who holds a store lock.
StoreLock
Locks held for one invocation; dropping it releases them.
StoreLockOptions
The parsed --lock, --no-lock and --lock-timeout options.

Enums§

Liveness
Whether the owner of a lock still runs, as far as this host can tell.
StoreLockKind
The --lock mechanism.

Constants§

DEFAULT_LOCK_TIMEOUT_MS
How long a waiter waits by default, in milliseconds.

Functions§

lock_dir_path
<db>.lock.d.
lock_order
The stores of one invocation without duplicates, in the order every process locks them: sorted by absolute path. Each keeps the spelling it was given, which is what messages show.
lock_status
--lock-status: one line per store and lock kind, without taking or creating any lock that is not already there.
owner_file_path
<db>.lock.owner: the record of the exclusive flock holder.