Prevent potential goroutine leak

This commit is contained in:
Viktor Liu
2025-06-02 19:44:13 +02:00
parent ef5027ab2a
commit fdb155f34b

View File

@@ -406,7 +406,10 @@ func (w *Watcher) disconnectEvent(route *route.Route, rsn reason) {
func (w *Watcher) SendUpdate(update RoutesUpdate) {
go func() {
w.routeUpdate <- update
select {
case w.routeUpdate <- update:
case <-w.ctx.Done():
}
}()
}
@@ -487,9 +490,9 @@ func (w *Watcher) Stop() {
w.cancel()
if w.currentChosen == nil {
return
}
if w.currentChosen == nil {
return
}
if err := w.removeAllowedIPs(w.currentChosen, reasonShutdown); err != nil {
log.Errorf("Failed to remove routes for [%v]: %v", w.handler, err)
}