Refactor network monitor to wait for stop (#1992)

This commit is contained in:
Viktor Liu
2024-05-17 09:43:18 +02:00
committed by GitHub
parent a5811a2d7d
commit bd58eea8ea
7 changed files with 74 additions and 52 deletions
@@ -48,10 +48,10 @@ func checkChange(ctx context.Context, nexthopv4 netip.Addr, intfv4 *net.Interfac
for {
select {
case <-ctx.Done():
return ctx.Err()
return ErrStopped
case <-ticker.C:
if changed(nexthopv4, intfv4, neighborv4, nexthopv6, intfv6, neighborv6) {
callback()
go callback()
return nil
}
}