mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-14 17:39:12 +02:00
use peer.Status.LastSeen field to detect stale peer.Status.Connected values
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
This commit is contained in:
@@ -423,6 +423,7 @@ func (s *Server) handleUpdates(ctx context.Context, accountID string, peerKey wg
|
||||
// Create a debouncer for this peer connection
|
||||
debouncer := NewUpdateDebouncer(1000 * time.Millisecond)
|
||||
defer debouncer.Stop()
|
||||
ticker := time.NewTicker(1 * time.Second)
|
||||
|
||||
for {
|
||||
select {
|
||||
@@ -448,6 +449,8 @@ func (s *Server) handleUpdates(ctx context.Context, accountID string, peerKey wg
|
||||
}
|
||||
}
|
||||
|
||||
s.accountManager.RefreshPeerLastSeen(ctx, accountID, peer.ID)
|
||||
|
||||
// Timer expired - quiet period reached, send pending updates if any
|
||||
case <-debouncer.TimerChannel():
|
||||
pendingUpdates := debouncer.GetPendingUpdates()
|
||||
@@ -462,6 +465,11 @@ func (s *Server) handleUpdates(ctx context.Context, accountID string, peerKey wg
|
||||
}
|
||||
}
|
||||
|
||||
s.accountManager.RefreshPeerLastSeen(ctx, accountID, peer.ID)
|
||||
|
||||
case <-ticker.C:
|
||||
s.accountManager.RefreshPeerLastSeen(ctx, accountID, peer.ID)
|
||||
|
||||
// condition when client <-> server connection has been terminated
|
||||
case <-srv.Context().Done():
|
||||
// happens when connection drops, e.g. client disconnects
|
||||
|
||||
Reference in New Issue
Block a user