lock while checking + setting move state

This commit is contained in:
tobi 2024-03-12 17:56:15 +01:00
parent 1ba04553af
commit d9f1e0e458
2 changed files with 15 additions and 0 deletions

View file

@ -107,6 +107,15 @@ func (p *Processor) MoveSelf(
targetAcctable ap.Accountable
)
// Next steps involve checking + setting
// state that might get messed up if a
// client triggers this function twice
// in quick succession, so get a lock on
// this account's moves.
lockKey := originAcct.URI + "/moves"
unlock := p.state.ClientLocks.Lock(lockKey)
defer unlock()
// Ensure we have a valid, up-to-date representation of the target account.
targetAcct, targetAcctable, err = p.federator.GetAccountByURI(
ctx,

View file

@ -50,6 +50,12 @@ type State struct {
// functions, and by the go-fed/activity library.
FedLocks mutexes.MutexMap
// ClientLocks provides access to this state's
// mutex map of per URI client locks.
//
// Used during account migration actions.
ClientLocks mutexes.MutexMap
// Storage provides access to the storage driver.
Storage *storage.Driver