[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:
@@ -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)?;
|
||||
|
||||
Reference in New Issue
Block a user