mirror of
https://github.com/lukaszraczylo/kportal.git
synced 2026-06-05 23:03:40 +00:00
3f11219dc1
CI on Linux flagged a race in TestStartWorker_HealthCallback_StatusChange:
the test read ui.updates while the healthchecker's per-port goroutine
(spawned by Register at checker.go:164) was still running and could
fire UpdateStatus through notifyStatusChange.
The earlier mutex on MockStatusUpdater protected the writes; the read
side was unprotected, and the goroutine had not finished by the time
the test started ranging over the slice on slower runners.
Fix:
- call healthChecker.Unregister(fwd.ID()) to drain the per-port
goroutine before reading
- hold ui.mu around the slice read for belt-and-suspenders happens-
before, regardless of goroutine timing
Verified locally with go test -race -count=20 on the targeted test
and -count=3 on the full forward package.