Add an exponential back off upon accept failure

pull/71/head
Eugene Kim 6 years ago
parent bf44dce3c6
commit 8ba4f7ac5d
  1. 3
      node/node.go

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"net" "net"
"sync" "sync"
"time"
"github.com/simple-rules/harmony-benchmark/blockchain" "github.com/simple-rules/harmony-benchmark/blockchain"
"github.com/simple-rules/harmony-benchmark/client" "github.com/simple-rules/harmony-benchmark/client"
@ -93,11 +94,13 @@ func (node *Node) listenOnPort(port string) {
return return
} }
defer listen.Close() defer listen.Close()
backoff := p2p.NewExpBackoff(250*time.Millisecond, 15*time.Second, 2.0)
for { for {
conn, err := listen.Accept() conn, err := listen.Accept()
if err != nil { if err != nil {
node.log.Error("Error listening on port.", "port", port, node.log.Error("Error listening on port.", "port", port,
"err", err) "err", err)
backoff.Sleep()
continue continue
} }
go node.NodeHandler(conn) go node.NodeHandler(conn)

Loading…
Cancel
Save