Skip to content

Commit

Permalink
p2p: avoid spinning loop on out-of-handles (ethereum#21878)
Browse files Browse the repository at this point in the history
* p2p: avoid busy-loop on temporary errors

* p2p: address review concerns
  • Loading branch information
holiman authored and enriquefynn committed Feb 15, 2021
1 parent c25f53b commit e336128
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions p2p/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,13 +854,18 @@ func (srv *Server) listenLoop() {
<-slots

var (
fd net.Conn
err error
fd net.Conn
err error
lastLog time.Time
)
for {
fd, err = srv.listener.Accept()
if netutil.IsTemporaryError(err) {
srv.log.Debug("Temporary read error", "err", err)
if time.Since(lastLog) > 1*time.Second {
srv.log.Debug("Temporary read error", "err", err)
lastLog = time.Now()
}
time.Sleep(time.Millisecond * 200)
continue
} else if err != nil {
srv.log.Debug("Read error", "err", err)
Expand Down

0 comments on commit e336128

Please sign in to comment.