fix(GODT-2426): Fix crash on user delete

Ensure we are always acquiring a write lock when modifying the user's
`updateCh` contents.
This commit is contained in:
Leander Beernaert
2023-03-01 11:10:34 +01:00
committed by James Houlahan
parent 9e4310712c
commit 69aa784d32
2 changed files with 2 additions and 2 deletions

View File

@ -257,7 +257,7 @@ func (user *User) handleUpdateAddressEvent(_ context.Context, event proton.Addre
}) })
return nil return nil
}, user.apiAddrsLock) }, user.apiAddrsLock, user.updateChLock)
} }
func (user *User) handleDeleteAddressEvent(_ context.Context, event proton.AddressEvent) error { func (user *User) handleDeleteAddressEvent(_ context.Context, event proton.AddressEvent) error {

View File

@ -546,7 +546,7 @@ func (user *User) Close() {
user.client.Close() user.client.Close()
// Close the user's update channels. // Close the user's update channels.
safe.RLock(func() { safe.Lock(func() {
for _, updateCh := range xslices.Unique(maps.Values(user.updateCh)) { for _, updateCh := range xslices.Unique(maps.Values(user.updateCh)) {
updateCh.CloseAndDiscardQueued() updateCh.CloseAndDiscardQueued()
} }