From 980ca8d495635a4c3d7cd781de48bdc6134ac320 Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Wed, 10 Jun 2020 16:18:20 -0400 Subject: [PATCH] fix: PeerManager signalAvailabiity() race --- internal/peermanager/peermanager.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/peermanager/peermanager.go b/internal/peermanager/peermanager.go index 00857627..1d4538a7 100644 --- a/internal/peermanager/peermanager.go +++ b/internal/peermanager/peermanager.go @@ -231,6 +231,9 @@ func (pm *PeerManager) UnregisterSession(ses uint64) { // signalAvailability is called when a peer's connectivity changes. // It informs interested sessions. func (pm *PeerManager) signalAvailability(p peer.ID, isConnected bool) { + pm.psLk.Lock() + defer pm.psLk.Unlock() + sesIds, ok := pm.peerSessions[p] if !ok { return