The read loop added to a handler's drop count with atomic.AddUint64 while GetHandlerStats (behind /api/v1/stats) and the ten-second metrics log read it as a plain field. The count is now an atomic.Uint64 read with Load, like the total beside it.
Run gave the HTTP server its WHOIS fetcher after the server had started, while request handlers read it without a lock. The fetcher is now created, started and set before server.Start, and the SetASNFetcher doc comment says to call it first.
What the diff does not show:
The new test has no assertion that fails before the fix; it fails through the race detector, which reports the add in the read loop against the read in GetHandlerStats.
It polls GetHandlerStats in a loop with no sleep instead of waiting for a signal from the read loop: such a signal would order the drops before the reads and hide the race.
If the server cannot listen, the fetcher is now already running; Shutdown stops it, as it stops the streamer, which already started before the server.
Disclosures:
Unverified: the fetcher change has no test, since none can make a request arrive between the server starting and the fetcher being set.
internal/server/server.go changes only in that doc comment.
Model: opus-5-5
Implements https://git.eeqj.de/sneak/routewatch/issues/115.
The read loop added to a handler's drop count with `atomic.AddUint64` while `GetHandlerStats` (behind `/api/v1/stats`) and the ten-second metrics log read it as a plain field. The count is now an `atomic.Uint64` read with `Load`, like the total beside it.
`Run` gave the HTTP server its WHOIS fetcher after the server had started, while request handlers read it without a lock. The fetcher is now created, started and set before `server.Start`, and the `SetASNFetcher` doc comment says to call it first.
What the diff does not show:
- The new test has no assertion that fails before the fix; it fails through the race detector, which reports the add in the read loop against the read in `GetHandlerStats`.
- It polls `GetHandlerStats` in a loop with no sleep instead of waiting for a signal from the read loop: such a signal would order the drops before the reads and hide the race.
- If the server cannot listen, the fetcher is now already running; `Shutdown` stops it, as it stops the streamer, which already started before the server.
Disclosures:
- Unverified: the fetcher change has no test, since none can make a request arrive between the server starting and the fetcher being set.
- `internal/server/server.go` changes only in that doc comment.
Model: opus-5-5
The read loop added to a handler's drop count atomically while the
statistics endpoint and the metrics log read it as a plain field, a data
race whenever messages were dropped. The count is now an atomic.Uint64,
read with Load. A test reads the handler statistics while the read loop
drops messages for a handler that never finishes one.
Run created the WHOIS fetcher and gave it to the HTTP server after the
server had started, while request handlers could read it. The fetcher is
now set before the server starts.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Implements #115.
The read loop added to a handler's drop count with
atomic.AddUint64whileGetHandlerStats(behind/api/v1/stats) and the ten-second metrics log read it as a plain field. The count is now anatomic.Uint64read withLoad, like the total beside it.Rungave the HTTP server its WHOIS fetcher after the server had started, while request handlers read it without a lock. The fetcher is now created, started and set beforeserver.Start, and theSetASNFetcherdoc comment says to call it first.What the diff does not show:
GetHandlerStats.GetHandlerStatsin a loop with no sleep instead of waiting for a signal from the read loop: such a signal would order the drops before the reads and hide the race.Shutdownstops it, as it stops the streamer, which already started before the server.Disclosures:
internal/server/server.gochanges only in that doc comment.Model: opus-5-5
Review passed.
Model: opus-5-5