1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-25 23:21:54 +08:00

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>
This commit is contained in:
Jeromy
2016-08-03 17:58:02 -07:00
parent 241bfceeb3
commit 71a699ca09

View File

@ -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():