Repository navigation
bitswap: fix a minor data race - #3036
Merged
Merged
Conversation
Member
|
LGTH, but it would be great to have this explanation either as commit message or a comment. |
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>
whyrusleeping
force-pushed
the
fix/wlist-race
branch
from
August 4, 2016 10:33
4e1036d to
71a699c
Compare
Member
Author
|
@Kubuxu added more description to the commit message |
Member
|
Great, thank you. LGTM |
| case <-broadcastSignal.C: // resend unfulfilled wantlist keys | ||
| log.Event(ctx, "Bitswap.Rebroadcast.active") | ||
| for _, e := range bs.wm.wl.Entries() { | ||
| e := e |
Member
There was a problem hiding this comment.
add:
e := e // prevent data race
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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