mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2026-02-13 04:18:34 +00:00
Other(refactor): Sort safe.Mutex types before locking to prevent deadlocks
This change implements safe.Mutex and safe.RWMutex, which wrap the sync.Mutex and sync.RWMutex types and are assigned a globally unique integer ID. The safe.Lock and safe.RLock methods sort the mutexes by this integer ID before locking to ensure that locks for a given set of mutexes are always performed in the same order, avoiding deadlocks.
This commit is contained in:
@ -110,7 +110,7 @@ func (user *User) sync(ctx context.Context) error {
|
||||
|
||||
return nil
|
||||
})
|
||||
}, &user.apiUserLock, &user.apiAddrsLock, &user.updateChLock)
|
||||
}, user.apiUserLock, user.apiAddrsLock, user.updateChLock)
|
||||
}
|
||||
|
||||
func syncLabels(ctx context.Context, client *liteapi.Client, updateCh ...*queue.QueuedChannel[imap.Update]) error {
|
||||
|
||||
Reference in New Issue
Block a user