Skip to main content

Module live

Module live 

Source
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§

Lock
Renewal
What renewing a held lock did (Guard::renew).

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 pid still exists (signal 0 checks without sending).
call_limit
The stop’s model call’s limit, spent into the hook: what the harness’s budget leaves but AFTER_CALL for 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 (locked runs unlocked then too). For holding several at once (moves.rs with_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; alive tells whether a pid still runs.
locked
Runs f while holding an exclusive lock on <file>.lock (kept, never removed), so appends to file and taking it whole (a rename) never interleave: an append never lands in a file already taken. When the lock cannot be taken f runs 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_ms for the lock’s holder to finish; the lock’s state after.