- 2001
- 2002
/// A child being spawned holds a duplicate of every open descriptor - 2003
/// until it execs; the duplicate here stands in for one. - 2004
#[test] - 2005
fn the_lock_lasts_exactly_as_long_as_the_handle() { - 2006
let dir = tempfile::tempdir().unwrap(); - 2007
let path = dir.path().join("session.jsonl"); - 2008
std::fs::write(&path, "").unwrap(); - 2009
- 2010
let log = SessionLog::open(path.clone()).unwrap(); - 2011
assert!(matches!( - 2012
SessionLog::open(path.clone()), - 2013
Err(SessionError::Locked(_)) - 2014
)); - 2015
- 2016
let duplicate = log.file.file.try_clone().unwrap(); - 2017
drop(log); - 2018
SessionLog::open(path).expect("the dropped handle's lock stayed with a duplicate"); - 2019
drop(duplicate); - 2020
} - 2021
} - 2022
source · Rust
Log
crates/vak-session/src/log.rs80.7 KB2,022 lines75 anchorsSnapshot ed4ab258