From 4052ec532b7f963ef738f8c5fb0b32759571e8f5 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 6 May 2020 18:43:35 +0300 Subject: [PATCH] Fix potential double locking when finding shared rooms --- matrix/rooms/roomcache.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/matrix/rooms/roomcache.go b/matrix/rooms/roomcache.go index d66078c..067cbb6 100644 --- a/matrix/rooms/roomcache.go +++ b/matrix/rooms/roomcache.go @@ -74,6 +74,8 @@ func (cache *RoomCache) IsEncrypted(roomID id.RoomID) bool { } 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() for _, room := range cache.Map { if !room.Encrypted { @@ -85,6 +87,7 @@ func (cache *RoomCache) FindSharedRooms(userID id.UserID) (shared []id.RoomID) { } } cache.Unlock() + cache.EnableUnloading() return }