Skip to content

Commit b9ee2fe

Browse files
ppennaCopilot
andcommitted
nvx: wait for a launch log's claim release with the shared claim wait
LockedState::released_claim, which rechecks whether a process still holds an interrupted launch's log claim, bounded the recheck with a literal one second. The scratch module already names that wait, CLAIM_RELEASE_WAIT, with its reason: a process that another thread of the caller spawns holds an inherited copy of a claim from its fork until it executes its program. The launch log's claim is inherited the same way: its flock on Linux, and on Windows its open handles when the log has no job, though not the job-based claim. released_claim now waits CLAIM_RELEASE_WAIT, whose doc comment also names the log claim and when it is inherited, so one constant bounds both waits. The value stays one second and the expression keeps its form, so recovery waits exactly as long as before. Both modules build only with the cli feature. The store and scratch unit tests pass unchanged at 8d47379 and after the change on Windows: 45 passed, 2 ignored. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8d47379 commit b9ee2fe

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎nvx/src/host/cli/store/launch.rs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Locked launch transitions and bounded recovery of an interrupted launch.
22
33
use std::thread;
4-
use std::time::{Duration, Instant};
4+
use std::time::Instant;
55

66
use super::StateFile;
77
use super::files;
@@ -10,6 +10,7 @@ use super::record::{LaunchJournal, RuntimeRecord};
1010
use crate::host::cli::deadline::RETRY_INTERVAL;
1111
use crate::host::process::{BootId, KILL_TIMEOUT, Opened, Process, ProcessRef};
1212
use crate::host::runtime::RuntimeIdentity;
13+
use crate::host::sandbox::scratch::CLAIM_RELEASE_WAIT;
1314
use crate::host::vm::{Prepared, SavedVm};
1415
use crate::{Error, ErrorKind, Result};
1516

@@ -73,9 +74,9 @@ impl LockedState {
7374
}
7475
}
7576

76-
/// Rechecks transient fork-inherited descriptors for at most one second.
77+
/// Rechecks transient fork-inherited descriptors for at most [`CLAIM_RELEASE_WAIT`].
7778
fn released_claim(&self, journal: &LaunchJournal, deadline: Instant) -> Result<bool> {
78-
let until = deadline.min(Instant::now() + Duration::from_secs(1));
79+
let until = deadline.min(Instant::now() + CLAIM_RELEASE_WAIT);
7980
loop {
8081
if !self.claim_held(journal)? {
8182
return Ok(true);

‎nvx/src/host/sandbox/scratch.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ const SCRATCH_BINDING_VERSION: u32 = 1;
6565

6666
/// How long a check of a scratch image that should be free waits for its claim to be released:
6767
/// long enough for a process that another thread of the caller spawned to execute its program,
68-
/// and so to close its copy of a claim, as [Claims](self#claims) explains.
68+
/// and so to close its copy of a claim, as [Claims](self#claims) explains. The sandbox store
69+
/// waits as long for the claim on an interrupted launch's log, which such a process holds the
70+
/// same way on Linux, and on Windows while the claim is the log's open handles.
6971
pub(crate) const CLAIM_RELEASE_WAIT: Duration = Duration::from_secs(1);
7072

7173
/// How often a check tries a claim that is held again.

0 commit comments

Comments
 (0)