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 <why@ipfs.io>
Jeromy committed
Aug 3, 2016 at 17:58 UTC
71a699ca09fcfe72d1c1ff866cc9ed67615dd227
1 file changed
+1
exchange/bitswap/workers.go
+1
@@ -173,6 +173,7 @@ func (bs *Bitswap) rebroadcastWorker(parent context.Context) {
173
case <-broadcastSignal.C: // resend unfulfilled wantlist keys
174
log.Event(ctx, "Bitswap.Rebroadcast.active")
175
for _, e := range bs.wm.wl.Entries() {
176
+ e := e
177
bs.findKeys <- &e
178
}
179
case <-parent.Done():