mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-07 17:21:49 -10:00
horizon-server: the lock test waits for a fork-held descriptor to close
Tests in the same binary spawn processes (tar, the engine); between fork and exec the child holds a copy of every open descriptor, the lock's too, so relocking right after drop could see WouldBlock. Seen twice on CI (#1833, #1895). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
8177a6f450
commit
4513af8995
1 file changed
+11
-1
@@ -849,7 +849,17 @@ mod tests {
|
||||
let first = lock(&dir).unwrap();
|
||||
assert!(lock(&dir).unwrap_err().contains("already running"));
|
||||
drop(first);
|
||||
lock(&dir).unwrap();
|
||||
// A process another test spawns holds a copy of the lock's descriptor between its fork and exec:
|
||||
// the lock comes back once that child has exec'd.
|
||||
let mut again = lock(&dir);
|
||||
for _ in 0..50 {
|
||||
if again.is_ok() {
|
||||
break;
|
||||
}
|
||||
std::thread::sleep(std::time::Duration::from_millis(20));
|
||||
again = lock(&dir);
|
||||
}
|
||||
again.unwrap();
|
||||
std::fs::remove_dir_all(&dir).unwrap();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user