Skip to content

Commit 81e9cae

Browse files
ethstats: avoid blocking chan when received invalid stats request (#21073)
* ethstats: avoid blocking chan when received invalid stats request * ethstats: minor code polishes Co-authored-by: Péter Szilágyi <peterke@gmail.com>
1 parent 7ddb402 commit 81e9cae

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎ethstats/ethstats.go‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,11 @@ func (s *Service) readLoop(conn *websocket.Conn) {
320320
request, ok := msg["emit"][1].(map[string]interface{})
321321
if !ok {
322322
log.Warn("Invalid stats history request", "msg", msg["emit"][1])
323-
s.histCh <- nil
324-
continue // Ethstats sometime sends invalid history requests, ignore those
323+
select {
324+
case s.histCh <- nil: // Treat it as an no indexes request
325+
default:
326+
}
327+
continue
325328
}
326329
list, ok := request["list"].([]interface{})
327330
if !ok {
@@ -349,7 +352,7 @@ func (s *Service) readLoop(conn *websocket.Conn) {
349352
}
350353
}
351354

352-
// nodeInfo is the collection of metainformation about a node that is displayed
355+
// nodeInfo is the collection of meta information about a node that is displayed
353356
// on the monitoring page.
354357
type nodeInfo struct {
355358
Name string `json:"name"`

0 commit comments

Comments
 (0)