move login counter metrics

This commit is contained in:
Pascal Fischer
2025-05-08 16:30:52 +02:00
parent 6b86350b9d
commit 0267cd1ddd
2 changed files with 12 additions and 3 deletions

View File

@@ -475,6 +475,13 @@ func (am *DefaultAccountManager) AddPeer(ctx context.Context, setupKey, userID s
return nil, nil, nil, status.Errorf(status.NotFound, "failed adding new peer: account not found")
}
unlock := am.Store.AcquireWriteLockByUID(ctx, accountID)
defer func() {
if unlock != nil {
unlock()
}
}()
// This is a handling for the case when the same machine (with the same WireGuard pub key) tries to register twice.
// Such case is possible when AddPeer function takes long time to finish after AcquireWriteLockByUID (e.g., database is slow)
// and the peer disconnects with a timeout and tries to register again.