From 68c1a13195b04f9cfcd88288d165a2917fd14e70 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 6 Apr 2022 12:55:37 +0100 Subject: [PATCH] Take map lock --- syncapi/notifier/notifier.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/syncapi/notifier/notifier.go b/syncapi/notifier/notifier.go index a06d6bf2e..4e1a3c2a3 100644 --- a/syncapi/notifier/notifier.go +++ b/syncapi/notifier/notifier.go @@ -250,6 +250,8 @@ func (n *Notifier) OnNewPresence( } func (n *Notifier) SharedUsers(userID string) (sharedUsers []string) { + n.mapLock.RLock() + defer n.mapLock.RUnlock() for roomID, users := range n.roomIDToJoinedUsers { if _, ok := users[userID]; ok { sharedUsers = append(sharedUsers, n.JoinedUsers(roomID)...) @@ -259,6 +261,8 @@ func (n *Notifier) SharedUsers(userID string) (sharedUsers []string) { } func (n *Notifier) IsSharedUser(userA, userB string) bool { + n.mapLock.RLock() + defer n.mapLock.RUnlock() var okA, okB bool for _, users := range n.roomIDToJoinedUsers { _, okA = users[userA]