From e4111471d43746f0982a96f31921417c3d85b3f2 Mon Sep 17 00:00:00 2001 From: Janos Guljas Date: Mon, 11 Feb 2019 11:03:39 +0100 Subject: [PATCH] swarm/network: protect addrCountC in Kademlia.AddrCountC function https://github.com/ethersphere/go-ethereum/issues/1198#issuecomment-462273444 --- swarm/network/kademlia.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/swarm/network/kademlia.go b/swarm/network/kademlia.go index 9f4245603f..1193e3b652 100644 --- a/swarm/network/kademlia.go +++ b/swarm/network/kademlia.go @@ -353,6 +353,9 @@ func (k *Kademlia) sendNeighbourhoodDepthChange() { // Not receiving from the returned channel will block Register function // when address count value changes. func (k *Kademlia) AddrCountC() <-chan int { + k.lock.Lock() + defer k.lock.Unlock() + if k.addrCountC == nil { k.addrCountC = make(chan int) }