Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

fix: avoid taking accessing the peerQueues without taking the lock #412

Merged
merged 2 commits into from
Jun 10, 2020

Conversation

Stebalien
Copy link
Member

Or, really, just avoid accessing it. We don't need it.

This caused a concurrent map access panic under load.

Or, really, just avoid accessing it. We don't need it.

This caused a concurrent map access panic under load.
@@ -210,9 +210,6 @@ func (pm *PeerManager) RegisterSession(p peer.ID, s Session) bool {
pm.peerSessions[p] = make(map[uint64]struct{})
}
pm.peerSessions[p][s.ID()] = struct{}{}

_, ok := pm.peerQueues[p]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to take the pm.pqLk before accessing this.

@Stebalien Stebalien requested a review from dirkmc June 10, 2020 02:07
@Stebalien
Copy link
Member Author

@dirkmc this should be good but could you double check tomorrow?

@Stebalien Stebalien merged commit 25318da into master Jun 10, 2020
@Stebalien Stebalien deleted the fix/race branch June 10, 2020 02:10
@dirkmc
Copy link
Contributor

dirkmc commented Jun 10, 2020

LGTM 👍

I think the bool return value must have been from a previous iteration, but looks like we don't need it

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants