From 09baeec0dabc24050f344272ed36e39687c2b4e8 Mon Sep 17 00:00:00 2001 From: Zsolt Felfoldi Date: Fri, 11 Nov 2016 03:10:46 +0100 Subject: [PATCH 1/2] discv5: fixed state machine lockup bug --- p2p/discv5/net.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/p2p/discv5/net.go b/p2p/discv5/net.go index afc92e99f..b08cd2bc7 100644 --- a/p2p/discv5/net.go +++ b/p2p/discv5/net.go @@ -863,6 +863,9 @@ func init() { name: "verifywait", handle: func(net *Network, n *Node, ev nodeEvent, pkt *ingressPacket) (*nodeState, error) { switch ev { + case pingPacket: + net.handlePing(n, pkt) + return verifywait, nil case pongPacket: err := net.handleKnownPong(n, pkt) return known, err From 323c2d6775c86c063e9048ef0e8605283f07cafb Mon Sep 17 00:00:00 2001 From: Zsolt Felfoldi Date: Fri, 11 Nov 2016 03:16:46 +0100 Subject: [PATCH 2/2] les: add missing nil check and handle quit in findServers --- les/handler.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/les/handler.go b/les/handler.go index 44a0a1661..cf698d79c 100644 --- a/les/handler.go +++ b/les/handler.go @@ -236,7 +236,7 @@ func (pm *ProtocolManager) removePeer(id string) { } func (pm *ProtocolManager) findServers() { - if pm.p2pServer == nil { + if pm.p2pServer == nil || pm.topicDisc == nil { return } enodes := make(chan string, 100) @@ -259,7 +259,10 @@ func (pm *ProtocolManager) findServers() { } } }() - time.Sleep(time.Second * 20) + select { + case <-time.After(time.Second * 20): + case <-pm.quitSync: + } close(stop) }