Fix potential double locking when finding shared rooms

This commit is contained in:
Tulir Asokan 2020-05-06 18:43:35 +03:00
parent 5927733562
commit 4052ec532b

View File

@ -74,6 +74,8 @@ func (cache *RoomCache) IsEncrypted(roomID id.RoomID) bool {
} }
func (cache *RoomCache) FindSharedRooms(userID id.UserID) (shared []id.RoomID) { func (cache *RoomCache) FindSharedRooms(userID id.UserID) (shared []id.RoomID) {
// FIXME this disables unloading so TouchNode wouldn't try to double-lock
cache.DisableUnloading()
cache.Lock() cache.Lock()
for _, room := range cache.Map { for _, room := range cache.Map {
if !room.Encrypted { if !room.Encrypted {
@ -85,6 +87,7 @@ func (cache *RoomCache) FindSharedRooms(userID id.UserID) (shared []id.RoomID) {
} }
} }
cache.Unlock() cache.Unlock()
cache.EnableUnloading()
return return
} }