mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-04 05:43:06 +00:00
fix close race in basicTracer
This commit is contained in:
parent
faf920414d
commit
a613f097ed
@ -46,8 +46,9 @@ type basicTracer struct {
|
|||||||
|
|
||||||
func (t *basicTracer) Trace(evt *pb.TraceEvent) {
|
func (t *basicTracer) Trace(evt *pb.TraceEvent) {
|
||||||
t.mx.Lock()
|
t.mx.Lock()
|
||||||
|
defer t.mx.Unlock()
|
||||||
|
|
||||||
if t.closed {
|
if t.closed {
|
||||||
t.mx.Unlock()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +57,6 @@ func (t *basicTracer) Trace(evt *pb.TraceEvent) {
|
|||||||
} else {
|
} else {
|
||||||
t.buf = append(t.buf, evt)
|
t.buf = append(t.buf, evt)
|
||||||
}
|
}
|
||||||
t.mx.Unlock()
|
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case t.ch <- struct{}{}:
|
case t.ch <- struct{}{}:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user