forked from cerc-io/plugeth
p2p: avoid spinning loop on out-of-handles (#21878)
* p2p: avoid busy-loop on temporary errors * p2p: address review concerns
This commit is contained in:
parent
ebb9591c4d
commit
3ef52775c4
@ -854,13 +854,18 @@ func (srv *Server) listenLoop() {
|
|||||||
<-slots
|
<-slots
|
||||||
|
|
||||||
var (
|
var (
|
||||||
fd net.Conn
|
fd net.Conn
|
||||||
err error
|
err error
|
||||||
|
lastLog time.Time
|
||||||
)
|
)
|
||||||
for {
|
for {
|
||||||
fd, err = srv.listener.Accept()
|
fd, err = srv.listener.Accept()
|
||||||
if netutil.IsTemporaryError(err) {
|
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
|
continue
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
srv.log.Debug("Read error", "err", err)
|
srv.log.Debug("Read error", "err", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user