fix: data race reported in #1070 (#1072)

This commit is contained in:
Prem Chaitanya Prathi 2024-03-25 21:03:21 +05:30 committed by GitHub
parent 826c7fb924
commit 6f1280e704
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -286,8 +286,8 @@ func (w *WakuRelay) Publish(ctx context.Context, message *pb.WakuMessage, opts .
return nil, errors.New("not enough peers to publish") return nil, errors.New("not enough peers to publish")
} }
w.topicsMutex.RLock() w.topicsMutex.Lock()
defer w.topicsMutex.RUnlock() defer w.topicsMutex.Unlock()
pubSubTopic, err := w.upsertTopic(params.pubsubTopic) pubSubTopic, err := w.upsertTopic(params.pubsubTopic)
if err != nil { if err != nil {