brokerd: recover a torn line in place, real dates only, bounded ttl, EMFILE

From the independent review of task 23. A torn last line followed by an empty
later file had its recovery written into the later file, which broke the
chain for good; the line is now ended in its own file. The log-name rule
takes months 01 to 12 and days 01 to 31 only. [approvals] ttl_ms is limited
to a day, the longest loopd waits after a pending frame. Running out of file
descriptors or memory pauses the listener instead of stopping brokerd (the
errors the previous fix skipped do not occur on Linux). args.rs's doc fixed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-22 21:48:24 -07:00
co-authored by Claude Opus 5.5
parent ba369f82ba
commit e08deb39a6
9 changed files with 157 additions and 42 deletions
+9 -5
View File
@@ -198,13 +198,17 @@ socket, stop it; `brokerd` removes a stale socket file by itself.
## brokerd-listener-lost
**What you see.** Either `brokerd` exits 1 after it had been serving, with
`brokerd: stopped serving: <error>` and this entry; or it keeps running and prints
`brokerd: cannot start a thread for a connection, so it was closed`. In both cases `loopd` reports
**What you see.** One of three lines, then this entry:
- `brokerd: cannot accept on accept-broker (or accept-admin) for now, retrying: <error>`. It keeps
running and tries every 200 ms; the line is printed once per episode.
- `brokerd: cannot start a thread for a connection, so it was closed`. It keeps running.
- `brokerd: stopped serving: <error>`, and it exits 1: any other failure of `accept`.
In both cases `loopd` reports
[broker-unavailable](#broker-unavailable) for the calls that were refused.
**Why.** The system refused `brokerd` something it needs to serve: `accept` failed on a socket for a
reason other than one aborted connection, or a thread could not be started. The usual cause is a
**Why.** The system refused `brokerd` something it needs to serve: a new connection (`accept`
failed) or a thread. The usual cause is a
limit: open files (`EMFILE`), processes or threads for the user, or memory. A connection that is
refused gets no decision, so nothing runs for it.