Skip to content

Commit

Permalink
fix race
Browse files Browse the repository at this point in the history
  • Loading branch information
amirylm committed Jul 5, 2024
1 parent 454e3de commit e356c3a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion core/pubsub_trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit e356c3a

Please sign in to comment.