Skip to content

Commit

Permalink
Remove unnecessary global lock (netbirdio#1178)
Browse files Browse the repository at this point in the history
  • Loading branch information
surik authored Sep 27, 2023
1 parent cbde826 commit c287d7b
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions management/server/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,6 @@ func (am *DefaultAccountManager) redeemInvite(account *Account, userID string) e

// MarkPATUsed marks a personal access token as used
func (am *DefaultAccountManager) MarkPATUsed(tokenID string) error {
unlock := am.Store.AcquireGlobalLock()

user, err := am.Store.GetUserByTokenID(tokenID)
if err != nil {
Expand All @@ -1255,8 +1254,7 @@ func (am *DefaultAccountManager) MarkPATUsed(tokenID string) error {
return err
}

unlock()
unlock = am.Store.AcquireAccountLock(account.Id)
unlock := am.Store.AcquireAccountLock(account.Id)
defer unlock()

account, err = am.Store.GetAccountByUser(user.Id)
Expand Down

0 comments on commit c287d7b

Please sign in to comment.