From ee8f333dbfd60f279336723d2f74a20b91ae642b Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Wed, 27 Jan 2021 10:33:50 +0100 Subject: [PATCH] Avoid concurrent access to contacts We were not locking before accessing the contacts map and it would panic in some cases. I have changed the code to pull contacts from db so we move away from having locks. --- VERSION | 2 +- protocol/messenger.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index a868f07b1..9cefff060 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.69.1 +0.69.2 diff --git a/protocol/messenger.go b/protocol/messenger.go index 6ff17e34f..7014bedc8 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -3292,7 +3292,11 @@ func (m *Messenger) MessageByChatID(chatID, cursor string, limit int) ([]*common if chat.Timeline() { var chatIDs = []string{"@" + contactIDFromPublicKey(&m.identity.PublicKey)} - for _, contact := range m.allContacts { + contacts, err := m.persistence.Contacts() + if err != nil { + return nil, "", err + } + for _, contact := range contacts { if contact.IsAdded() { chatIDs = append(chatIDs, "@"+contact.ID) }