From e356c3a7bbb44eea2f0cd1a231f19b4cdaea92c9 Mon Sep 17 00:00:00 2001 From: amirylm <83904651+amirylm@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:06:26 +0300 Subject: [PATCH] fix race --- core/pubsub_trace.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/core/pubsub_trace.go b/core/pubsub_trace.go index 075cc30..b165f99 100644 --- a/core/pubsub_trace.go +++ b/core/pubsub_trace.go @@ -54,6 +54,22 @@ func (tf *traceFaucets) add(other traceFaucets) { tf.recvRPC.Add(other.recvRPC.Load()) } +func (tf *traceFaucets) set(other traceFaucets) { + tf.join.Store(other.join.Load()) + tf.leave.Store(other.leave.Load()) + tf.publish.Store(other.publish.Load()) + tf.deliver.Store(other.deliver.Load()) + tf.reject.Store(other.reject.Load()) + tf.duplicate.Store(other.duplicate.Load()) + tf.addPeer.Store(other.addPeer.Load()) + tf.removePeer.Store(other.removePeer.Load()) + tf.graft.Store(other.graft.Load()) + tf.prune.Store(other.prune.Load()) + tf.sendRPC.Store(other.sendRPC.Load()) + tf.dropRPC.Store(other.dropRPC.Load()) + tf.recvRPC.Store(other.recvRPC.Load()) +} + type eventFields map[string]string func MarshalTraceEvents(events []eventFields) ([]byte, error) { @@ -93,7 +109,7 @@ func (pst *psTracer) Reset() { defer pst.lock.Unlock() pst.events = nil - pst.faucets = newTraceFaucets() + pst.faucets.set(newTraceFaucets()) } func (pst *psTracer) Events() []eventFields {