-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Motivation
FeedRIB starts RIB.CleanupTask goroutines that wait on quitCh (or a TTL) before mutating the RIB (service.go). Earlier audits claimed quitCh was never closed; on current main, RouteModule.Run closes quitCh when its context is cancelled, which matches the normal gateway/director lifecycle.
RouteModule.Close still does not close quitCh and only tears down the agent and shared memory (mod.go Close). Any shutdown path that calls Close() without the Run context having been cancelled first—or any future use of RouteService without this Run wiring—can leave CleanupTask running past teardown or rely only on the TTL branch.
Code
RouteModule.Run—close(quitCh)onctx.Done()RouteModule.Close— noquitChCleanupTaskselects onquitFeedRIBschedules cleanup
Possible solution
Make shutdown explicit and ordered: e.g. close quitCh from Close() using sync.Once (and adjust Run so you never double-close), or replace the bool channel with a context.Context cancelled in both paths. Document required call order for embedded tests.
Definition of done
All documented shutdown paths cancel cleanup tasks before agent/SHM teardown; no double-close panic; optional test covering Close/Run ordering.
Alternatives
If product guarantee is “Run always cancels before Close”, document that invariant in RouteModule and assert in tests instead of closing in two places.