Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 15 additions & 4 deletions src/agent/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::io::{self, BufRead, Cursor, Read};
use std::path::{Path, PathBuf};
use std::process::Command;
use std::sync::{Arc, Barrier};
use std::time::{Duration, Instant};

#[cfg(unix)]
use std::os::unix::fs::{MetadataExt as _, PermissionsExt as _, symlink};
Expand Down Expand Up @@ -523,10 +524,20 @@ fn a_separate_writer_lock_refuses_without_replacement_and_retry_converges() {
assert_eq!(fs::read_dir(path.parent().unwrap()).unwrap().count(), 2);
#[cfg(unix)]
let lock_inode = fs::metadata(&lock_path).unwrap().ino();
assert_eq!(
confirmed(home.path(), Client::Cursor).result.unwrap(),
Outcome::Installed
);
// Another test in this process can spawn a process while the worker holds
// the lease. The child keeps an inherited copy of the lock descriptor
// until its exec, so the first retry can still find the lock taken. Retry
// within a bound; a lock that stays held still fails.
let deadline = Instant::now() + Duration::from_secs(10);
let retried = loop {
match confirmed(home.path(), Client::Cursor).result {
Err(InstallError::Busy(_)) if Instant::now() < deadline => {
std::thread::park_timeout(Duration::from_millis(20));
}
result => break result,
}
};
assert_eq!(retried.unwrap(), Outcome::Installed);
assert_eq!(
confirmed(home.path(), Client::Cursor).result.unwrap(),
Outcome::Existing
Expand Down
Loading