From a613f097ed5a94d44e7cd4327a336f111d9eb8ba Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 21 Apr 2020 21:02:12 +0300 Subject: [PATCH] fix close race in basicTracer --- tracer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tracer.go b/tracer.go index 63277d4..e587ba8 100644 --- a/tracer.go +++ b/tracer.go @@ -46,8 +46,9 @@ type basicTracer struct { func (t *basicTracer) Trace(evt *pb.TraceEvent) { t.mx.Lock() + defer t.mx.Unlock() + if t.closed { - t.mx.Unlock() return } @@ -56,7 +57,6 @@ func (t *basicTracer) Trace(evt *pb.TraceEvent) { } else { t.buf = append(t.buf, evt) } - t.mx.Unlock() select { case t.ch <- struct{}{}: