Explorar o código

les: add missing nil check and handle quit in findServers

Zsolt Felfoldi %!s(int64=9) %!d(string=hai) anos
pai
achega
323c2d6775
Modificáronse 1 ficheiros con 5 adicións e 2 borrados
  1. 5 2
      les/handler.go

+ 5 - 2
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)
 }