From 83b1734cc2b09b46574f2e59478cc446bdf3db05 Mon Sep 17 00:00:00 2001 From: Hao Duan Date: Wed, 13 May 2020 19:56:39 +0800 Subject: [PATCH 1/2] ethstats: avoid blocking chan when received invalid stats request --- ethstats/ethstats.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go index 6e1aad693ce0..4f9edf9f4341 100644 --- a/ethstats/ethstats.go +++ b/ethstats/ethstats.go @@ -320,8 +320,13 @@ func (s *Service) readLoop(conn *websocket.Conn) { request, ok := msg["emit"][1].(map[string]interface{}) if !ok { log.Warn("Invalid stats history request", "msg", msg["emit"][1]) - s.histCh <- nil - continue // Ethstats sometime sends invalid history requests, ignore those + select { + // treat it as an no indexes request in which we will return top ones block histories + case s.histCh <- nil: + continue + default: + continue + } } list, ok := request["list"].([]interface{}) if !ok { @@ -349,7 +354,7 @@ func (s *Service) readLoop(conn *websocket.Conn) { } } -// nodeInfo is the collection of metainformation about a node that is displayed +// nodeInfo is the collection of meta information about a node that is displayed // on the monitoring page. type nodeInfo struct { Name string `json:"name"` From 27c9f3e7c699f8bbbe64ed233f2050817bb8afb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 26 May 2020 11:55:54 +0300 Subject: [PATCH 2/2] ethstats: minor code polishes --- ethstats/ethstats.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go index 4f9edf9f4341..dae23cb80a42 100644 --- a/ethstats/ethstats.go +++ b/ethstats/ethstats.go @@ -321,12 +321,10 @@ func (s *Service) readLoop(conn *websocket.Conn) { if !ok { log.Warn("Invalid stats history request", "msg", msg["emit"][1]) select { - // treat it as an no indexes request in which we will return top ones block histories - case s.histCh <- nil: - continue + case s.histCh <- nil: // Treat it as an no indexes request default: - continue } + continue } list, ok := request["list"].([]interface{}) if !ok {