Expand description
The session lock, and the file locks every store append takes (locked).
Live mode, which checked the work during the turn from here, was removed in 0.7.6 (docs/delivery.md, “Live mode (removed in 0.7.6)”); the module kept its name and its lock file’s.
The session lock: <S>.live.lock beside the session’s state file, <pid> <started_ms>, held by a
stop for its whole check and by the session-end judge (hook.rs judge_session), so two judge calls
never judge the same deliveries at once. Linked into place whole; stale when its process is gone or
it is older than stale_ms.
Structs§
- Guard
- A held lock; dropping it removes the file, if it is still this one’s.
Enums§
Constants§
- AFTER_
CALL - Guard: what the stop’s model call leaves of the budget for the rest of the hook (its records and its answer), so the answer is out before the harness kills the hook.
Functions§
- acquire
- Takes the session’s lock for this process, or None when another holds it. The lock is written to a file of its own first and hard-linked into place, which fails when a lock is there: no one ever reads a half-written lock. A stale lock is moved aside (a rename: only one process gets it) and taken once more; when what was moved aside is no longer the stale lock seen, someone took it over first, and it goes back.
- alive
- Whether process
pidstill exists (signal 0 checks without sending). - call_
limit - The stop’s model call’s limit,
spentinto the hook: what the harness’s budget leaves butAFTER_CALLfor the rest of the hook, never over the model’s own limit. omp’s 28 s gives at most 25 s. - hold
- The lock of
file(<file>.lock), held until the returned file is dropped; None when it cannot be taken (lockedruns unlocked then too). For holding several at once (moves.rswith_locks). - lock_
file - The session lock’s file beside the state file
ctx. Its name is live mode’s: a lock an older binary holds across an upgrade still counts. - lock_
state - The lock’s state at
now;alivetells whether a pid still runs. - locked
- Runs
fwhile holding an exclusive lock on<file>.lock(kept, never removed), so appends tofileand taking it whole (a rename) never interleave: an append never lands in a file already taken. When the lock cannot be takenfruns unlocked: for a plain append no worse than without it. - stale_
ms - A lock older than this belongs to a holder that cannot still be waiting for its model (or to a pid
that was reused): derived, twice the predict timeout plus [
STALE_SLACK_MS]. - wait_
free - Waits up to
max_msfor the lock’s holder to finish; the lock’s state after.