Merge remote-tracking branch 'origin/fix/lost-peer-status-event' into apply-routes-early

This commit is contained in:
Viktor Liu
2025-06-02 19:42:58 +02:00
3 changed files with 77 additions and 27 deletions

View File

@@ -223,19 +223,17 @@ func (w *Watcher) getBestRouteFromStatuses(routePeerStatuses map[route.ID]router
}
func (w *Watcher) watchPeerStatusChanges(ctx context.Context, peerKey string, peerStateUpdate chan struct{}, closer chan struct{}) {
subscription := w.statusRecorder.SubscribeToPeerStateChanges(ctx, peerKey)
defer w.statusRecorder.UnsubscribePeerStateChanges(subscription)
for {
select {
case <-ctx.Done():
return
case <-closer:
return
case <-w.statusRecorder.GetPeerStateChangeNotifier(peerKey):
state, err := w.statusRecorder.GetPeer(peerKey)
if err != nil {
continue
}
case <-subscription.Events():
peerStateUpdate <- struct{}{}
log.Debugf("triggered route state update for Peer %s, state: %s", peerKey, state.ConnStatus)
log.Debugf("triggered route state update for Peer: %s", peerKey)
}
}
}