From 8ba4f7ac5d606df008e7d88672377efbe7b96af5 Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Fri, 14 Sep 2018 15:18:22 -0700 Subject: [PATCH] Add an exponential back off upon accept failure --- node/node.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/node/node.go b/node/node.go index e14a461fb..5e30dea0a 100644 --- a/node/node.go +++ b/node/node.go @@ -6,6 +6,7 @@ import ( "fmt" "net" "sync" + "time" "github.com/simple-rules/harmony-benchmark/blockchain" "github.com/simple-rules/harmony-benchmark/client" @@ -93,11 +94,13 @@ func (node *Node) listenOnPort(port string) { return } defer listen.Close() + backoff := p2p.NewExpBackoff(250*time.Millisecond, 15*time.Second, 2.0) for { conn, err := listen.Accept() if err != nil { node.log.Error("Error listening on port.", "port", port, "err", err) + backoff.Sleep() continue } go node.NodeHandler(conn)