diff --git a/management/server/account.go b/management/server/account.go index f42569542..d25fe5b79 100644 --- a/management/server/account.go +++ b/management/server/account.go @@ -1244,10 +1244,11 @@ func (am *DefaultAccountManager) handleInactivityExpirationSettings(ctx context. return nil } - - func (am *DefaultAccountManager) peerLoginExpirationJob(ctx context.Context, accountID string) func() (time.Duration, bool) { return func() (time.Duration, bool) { + unlock := am.Store.AcquireWriteLockByUID(ctx, accountID) + defer unlock() + expiredPeers, err := am.getExpiredPeers(ctx, accountID) if err != nil { return 0, false @@ -1279,6 +1280,9 @@ func (am *DefaultAccountManager) checkAndSchedulePeerLoginExpiration(ctx context // peerInactivityExpirationJob marks login expired for all inactive peers and returns the minimum duration in which the next peer of the account will expire by inactivity if found func (am *DefaultAccountManager) peerInactivityExpirationJob(ctx context.Context, accountID string) func() (time.Duration, bool) { return func() (time.Duration, bool) { + unlock := am.Store.AcquireWriteLockByUID(ctx, accountID) + defer unlock() + inactivePeers, err := am.getInactivePeers(ctx, accountID) if err != nil { log.WithContext(ctx).Errorf("failed getting inactive peers for account %s", accountID) diff --git a/management/server/ephemeral.go b/management/server/ephemeral.go index 6e245ec5a..111d5e3fc 100644 --- a/management/server/ephemeral.go +++ b/management/server/ephemeral.go @@ -127,15 +127,11 @@ func (e *EphemeralManager) loadEphemeralPeers(ctx context.Context) { } t := newDeadLine() - count := 0 for _, p := range peers { - if p.Ephemeral { - count++ - e.addPeer(p.AccountID, p.ID, t) - } + e.addPeer(p.AccountID, p.ID, t) } - log.WithContext(ctx).Debugf("loaded ephemeral peer(s): %d", count) + log.WithContext(ctx).Debugf("loaded ephemeral peer(s): %d", len(peers)) } func (e *EphemeralManager) cleanup(ctx context.Context) {