mirror of
https://github.com/netbirdio/netbird.git
synced 2026-05-18 22:59:57 +00:00
Prevent potential goroutine leak
This commit is contained in:
@@ -406,7 +406,10 @@ func (w *Watcher) disconnectEvent(route *route.Route, rsn reason) {
|
|||||||
|
|
||||||
func (w *Watcher) SendUpdate(update RoutesUpdate) {
|
func (w *Watcher) SendUpdate(update RoutesUpdate) {
|
||||||
go func() {
|
go func() {
|
||||||
w.routeUpdate <- update
|
select {
|
||||||
|
case w.routeUpdate <- update:
|
||||||
|
case <-w.ctx.Done():
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,9 +490,9 @@ func (w *Watcher) Stop() {
|
|||||||
|
|
||||||
w.cancel()
|
w.cancel()
|
||||||
|
|
||||||
if w.currentChosen == nil {
|
if w.currentChosen == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := w.removeAllowedIPs(w.currentChosen, reasonShutdown); err != nil {
|
if err := w.removeAllowedIPs(w.currentChosen, reasonShutdown); err != nil {
|
||||||
log.Errorf("Failed to remove routes for [%v]: %v", w.handler, err)
|
log.Errorf("Failed to remove routes for [%v]: %v", w.handler, err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user