fix(mcp): the test knob's held-lines are each one write, so two timers never run their names together
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
943566bebd
commit
ed2dea9a8e
1 file changed
+20
-30
@@ -992,6 +992,23 @@ impl Drop for CloseGuard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The test knob `--timer-hold`: say in `run/timer-held` that `name` is
|
||||||
|
/// held, as one line. The line, its newline included, goes out in one
|
||||||
|
/// `write` on a file opened for append: `writeln!` on a `File` is a write
|
||||||
|
/// for the name and another for the newline, so two writers (the sweep and
|
||||||
|
/// the backup, on a loaded machine) could interleave and leave "backupsweep"
|
||||||
|
/// and an empty line where each was to say its own name.
|
||||||
|
fn say_held(run: &std::path::Path, name: &str) {
|
||||||
|
use std::io::Write;
|
||||||
|
if let Ok(mut said) = std::fs::OpenOptions::new()
|
||||||
|
.create(true)
|
||||||
|
.append(true)
|
||||||
|
.open(run.join("timer-held"))
|
||||||
|
{
|
||||||
|
let _ = said.write_all(format!("{name}\n").as_bytes());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Books {
|
impl Books {
|
||||||
/// A server's books for `root`, none held yet.
|
/// A server's books for `root`, none held yet.
|
||||||
fn new(
|
fn new(
|
||||||
@@ -1097,16 +1114,7 @@ impl Books {
|
|||||||
let flag = flag.clone();
|
let flag = flag.clone();
|
||||||
stop.with_phase_watch(Arc::new(move |phase: &str| {
|
stop.with_phase_watch(Arc::new(move |phase: &str| {
|
||||||
let name = format!("{job}:{phase}");
|
let name = format!("{job}:{phase}");
|
||||||
{
|
say_held(&run, &name);
|
||||||
use std::io::Write;
|
|
||||||
if let Ok(mut said) = std::fs::OpenOptions::new()
|
|
||||||
.create(true)
|
|
||||||
.append(true)
|
|
||||||
.open(run.join("timer-held"))
|
|
||||||
{
|
|
||||||
let _ = writeln!(said, "{name}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let held = || {
|
let held = || {
|
||||||
std::fs::read_to_string(run.join("timer-hold"))
|
std::fs::read_to_string(run.join("timer-hold"))
|
||||||
.is_ok_and(|names| names.split(',').any(|n| n.trim() == name))
|
.is_ok_and(|names| names.split(',').any(|n| n.trim() == name))
|
||||||
@@ -1128,16 +1136,7 @@ impl Books {
|
|||||||
let Ok(run) = self.root.run_dir() else {
|
let Ok(run) = self.root.run_dir() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
{
|
say_held(&run, timer);
|
||||||
use std::io::Write;
|
|
||||||
if let Ok(mut said) = std::fs::OpenOptions::new()
|
|
||||||
.create(true)
|
|
||||||
.append(true)
|
|
||||||
.open(run.join("timer-held"))
|
|
||||||
{
|
|
||||||
let _ = writeln!(said, "{timer}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Held while the file names this timer (a list, comma-separated).
|
// Held while the file names this timer (a list, comma-separated).
|
||||||
let held = || {
|
let held = || {
|
||||||
std::fs::read_to_string(run.join("timer-hold"))
|
std::fs::read_to_string(run.join("timer-hold"))
|
||||||
@@ -1315,16 +1314,7 @@ impl Books {
|
|||||||
let flag = shared.hurry_flag();
|
let flag = shared.hurry_flag();
|
||||||
backups.set_hold(Arc::new(move |call: &str| {
|
backups.set_hold(Arc::new(move |call: &str| {
|
||||||
let name = format!("call:{call}");
|
let name = format!("call:{call}");
|
||||||
{
|
say_held(&run, &name);
|
||||||
use std::io::Write;
|
|
||||||
if let Ok(mut said) = std::fs::OpenOptions::new()
|
|
||||||
.create(true)
|
|
||||||
.append(true)
|
|
||||||
.open(run.join("timer-held"))
|
|
||||||
{
|
|
||||||
let _ = writeln!(said, "{name}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let held = || {
|
let held = || {
|
||||||
std::fs::read_to_string(run.join("timer-hold"))
|
std::fs::read_to_string(run.join("timer-hold"))
|
||||||
.is_ok_and(|names| names.split(',').any(|n| n.trim() == name))
|
.is_ok_and(|names| names.split(',').any(|n| n.trim() == name))
|
||||||
|
|||||||
Reference in new issue
Block a user