From 0a1bcdcbff55ef12b973f6005dce9b24c154ba8f Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Sat, 6 Sep 2025 17:18:22 +0800 Subject: [PATCH] ethstats: avoid blocking chan when received invalid stats request #21073 (#1441) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ethstats: avoid blocking chan when received invalid stats request * ethstats: minor code polishes Co-authored-by: Hao Duan Co-authored-by: Péter Szilágyi --- ethstats/ethstats.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go index 9f9bff357b..97f5749c20 100644 --- a/ethstats/ethstats.go +++ b/ethstats/ethstats.go @@ -399,9 +399,12 @@ func (s *Service) readLoop(conn *connWrapper) { // Make sure the request is valid and doesn't crash us request, ok := msg["emit"][1].(map[string]interface{}) if !ok { - log.Debug("Invalid stats history request", "msg", msg["emit"][1]) - s.histCh <- nil - continue // Ethstats sometime sends invalid history requests, ignore those + log.Warn("Invalid stats history request", "msg", msg["emit"][1]) + select { + case s.histCh <- nil: // Treat it as an no indexes request + default: + } + continue } list, ok := request["list"].([]interface{}) if !ok { @@ -429,7 +432,7 @@ func (s *Service) readLoop(conn *connWrapper) { } } -// 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"`