Skip to content

Commit

Permalink
Return 1s when next expiration is too low (netbirdio#1672)
Browse files Browse the repository at this point in the history
using the login expired issue could cause problems with ticker used in the scheduler

This change makes 1s the minimum number returned when rescheduling the peer expiration task
  • Loading branch information
mlsmaycon authored Mar 6, 2024
1 parent 39f3239 commit 06be430
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions management/server/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,11 @@ func (a *Account) GetNextPeerExpiration() (time.Duration, bool) {
}
_, duration := peer.LoginExpired(a.Settings.PeerLoginExpiration)
if nextExpiry == nil || duration < *nextExpiry {
// if expiration is below 1s return 1s duration
// this avoids issues with ticker that can't be set to < 0
if duration < time.Second {
return time.Second, true
}
nextExpiry = &duration
}
}
Expand Down

0 comments on commit 06be430

Please sign in to comment.