memoryd, proto, brokerd, bxctl: repeated error lines written once

Implemented-By: OpenCode session (model recorded in docs/implementer-log.md)
This commit is contained in:
2026-09-25 16:41:44 -07:00
parent b98f373ead
commit 3640d32de0
5 changed files with 54 additions and 82 deletions
+6 -6
View File
@@ -98,14 +98,15 @@ fn grouped(n: u64) -> String {
/// Ask `memoryd` and print its answer. `Err` is the line for stderr.
pub fn run(socket: &Path, ask: &Ask, timeout: Duration, out: &mut dyn Write) -> Result<(), String> {
let mut stream = UnixStream::connect(socket)
.map_err(|e| format!("cannot reach memoryd at {}: {e}", socket.display()))?;
let unreachable =
|e: &dyn std::fmt::Display| format!("cannot reach memoryd at {}: {e}", socket.display());
let mut stream = UnixStream::connect(socket).map_err(|e| unreachable(&e))?;
stream
.set_read_timeout(Some(timeout))
.map_err(|e| format!("cannot reach memoryd at {}: {e}", socket.display()))?;
.map_err(|e| unreachable(&e))?;
stream
.set_write_timeout(Some(timeout))
.map_err(|e| format!("cannot reach memoryd at {}: {e}", socket.display()))?;
.map_err(|e| unreachable(&e))?;
let msg = match ask {
Ask::Reindex => Message::Reindex(Empty {}),
@@ -120,8 +121,7 @@ pub fn run(socket: &Path, ask: &Ask, timeout: Duration, out: &mut dyn Write) ->
r#final: true,
msg,
};
write_frame(&mut stream, &env)
.map_err(|e| format!("cannot reach memoryd at {}: {e}", socket.display()))?;
write_frame(&mut stream, &env).map_err(|e| unreachable(&e))?;
let reply = read_frame(&mut stream).map_err(|e| format!("memoryd did not answer: {e}"))?;
let text = match reply.msg {