From 71a699ca09fcfe72d1c1ff866cc9ed67615dd227 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 3 Aug 2016 17:58:02 -0700 Subject: [PATCH] bitswap: fix a minor data race race detector picked up a minor race condition, Since loop iteration reuses the same local variable, its not safe to take its address and use it concurrently. The fix is to rebind the variable into a controlled scope (creating a new variable) and taking the address of that to pass outwards. License: MIT Signed-off-by: Jeromy --- exchange/bitswap/workers.go | 1 + 1 file changed, 1 insertion(+) diff --git a/exchange/bitswap/workers.go b/exchange/bitswap/workers.go index ec7236543de..4aa45791733 100644 --- a/exchange/bitswap/workers.go +++ b/exchange/bitswap/workers.go @@ -173,6 +173,7 @@ func (bs *Bitswap) rebroadcastWorker(parent context.Context) { case <-broadcastSignal.C: // resend unfulfilled wantlist keys log.Event(ctx, "Bitswap.Rebroadcast.active") for _, e := range bs.wm.wl.Entries() { + e := e bs.findKeys <- &e } case <-parent.Done():