From 044ae2fe01b6123fa66c34ad0111ca1da12a274e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Benkovsk=C3=BD?= Date: Sun, 2 Jun 2024 12:47:47 +0200 Subject: [PATCH] do not share err variable between worker goroutines --- pkg/dnsbench/benchmark.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/dnsbench/benchmark.go b/pkg/dnsbench/benchmark.go index 28935c3..ddbda38 100644 --- a/pkg/dnsbench/benchmark.go +++ b/pkg/dnsbench/benchmark.go @@ -363,7 +363,6 @@ func (b *Benchmark) Run(ctx context.Context) ([]*ResultStats, error) { st := newResultStats(b) stats[w] = st - var err error wg.Add(1) go func(workerID uint32, st *ResultStats) { defer func() { @@ -400,7 +399,6 @@ func (b *Benchmark) Run(ctx context.Context) ([]*ResultStats, error) { return } } - var resp *dns.Msg req := dns.Msg{} req.RecursionDesired = b.Recurse @@ -433,7 +431,7 @@ func (b *Benchmark) Run(ctx context.Context) ([]*ResultStats, error) { start := time.Now() reqTimeoutCtx, cancel := context.WithTimeout(ctx, b.RequestTimeout) - resp, err = query(reqTimeoutCtx, b.Server, &req) + resp, err := query(reqTimeoutCtx, b.Server, &req) cancel() dur := time.Since(start) if b.RequestLogEnabled {