From 8e4a9489c218d007c7d0ddde4bb2738fd7b1a5f7 Mon Sep 17 00:00:00 2001 From: Yusef Napora Date: Mon, 11 May 2020 11:14:23 -0400 Subject: [PATCH] lock for reading in bumpDeliveryTag --- tag_tracer.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tag_tracer.go b/tag_tracer.go index 7cc0cb5..fe81e72 100644 --- a/tag_tracer.go +++ b/tag_tracer.go @@ -52,7 +52,7 @@ var ( // The delivery tags have a maximum value, GossipSubConnTagMessageDeliveryCap, and they decay at // a rate of GossipSubConnTagDecayAmount / GossipSubConnTagDecayInterval. type tagTracer struct { - sync.Mutex + sync.RWMutex cmgr connmgr.ConnManager decayer connmgr.Decayer @@ -144,6 +144,9 @@ func (t *tagTracer) decayingDeliveryTag(topic string) (connmgr.DecayingTag, erro } func (t *tagTracer) bumpDeliveryTag(p peer.ID, topic string) error { + t.RLock() + defer t.RUnlock() + tag, ok := t.decaying[topic] if !ok { return fmt.Errorf("no decaying tag registered for topic %s", topic)