[control] Atomic writes: a temporary name unique per write (pid, counter, random), so two writers of one file never collide; same for edge's epoch floor

This commit is contained in:
2026-11-07 19:57:06 +01:00
parent 7863202e3a
commit afc3477b5c
2 changed files with 33 additions and 2 deletions
+7 -1
View File
@@ -463,7 +463,13 @@ fn write_epoch_floor(rt: &Runtime, epoch: u32) -> std::io::Result<()> {
if let Some(dir) = path.parent() {
std::fs::create_dir_all(dir)?;
}
let tmp = path.with_extension("tmp");
// Unique per write: the admin socket and the poller can both reload the revocations.
static WRITES: AtomicU64 = AtomicU64::new(0);
let tmp = path.with_extension(format!(
"tmp-{}-{}",
std::process::id(),
WRITES.fetch_add(1, Ordering::Relaxed)
));
{
use std::io::Write;
let mut f = std::fs::File::create(&tmp)?;