Fix potential double locking when finding shared rooms
This commit is contained in:
		@@ -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
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user