Try to send out a message 10 times, then give up

This is to eliminate goroutine leaks.
pull/74/head
Eugene Kim 6 years ago
parent f4b19d3bcd
commit c6cd5c055d
  1. 5
      p2p/peer.go

@ -128,15 +128,16 @@ func send(ip, port string, message []byte) {
backoff := NewExpBackoff(250*time.Millisecond, 10*time.Second, 2)
for {
for trial := 0; trial < 10; trial++ {
err := sendWithSocketClient(ip, port, message)
if err == nil {
break
return
}
log.Info("sleeping before trying to send again",
"duration", backoff.Cur, "addr", net.JoinHostPort(ip, port))
backoff.Sleep()
}
log.Error("gave up sending a message", "addr", net.JoinHostPort(ip, port))
}
func DialWithSocketClient(ip, port string) (conn net.Conn, err error) {

Loading…
Cancel
Save