Commit 3fbf157a authored by Jeromy's avatar Jeromy

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: default avatarJeromy <why@ipfs.io>
parent eaefd13e
...@@ -173,6 +173,7 @@ func (bs *Bitswap) rebroadcastWorker(parent context.Context) { ...@@ -173,6 +173,7 @@ func (bs *Bitswap) rebroadcastWorker(parent context.Context) {
case <-broadcastSignal.C: // resend unfulfilled wantlist keys case <-broadcastSignal.C: // resend unfulfilled wantlist keys
log.Event(ctx, "Bitswap.Rebroadcast.active") log.Event(ctx, "Bitswap.Rebroadcast.active")
for _, e := range bs.wm.wl.Entries() { for _, e := range bs.wm.wl.Entries() {
e := e
bs.findKeys <- &e bs.findKeys <- &e
} }
case <-parent.Done(): case <-parent.Done():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment