mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
server: ensure a default backoff is always used
This commit is contained in:
parent
956d20ebdc
commit
4480052cd6
20
server.go
20
server.go
@ -1292,20 +1292,28 @@ func (s *server) peerTerminationWatcher(p *peer) {
|
||||
s.persistentConnReqs[pubStr] = append(
|
||||
s.persistentConnReqs[pubStr], connReq)
|
||||
|
||||
// Compute the subsequent backoff duration.
|
||||
currBackoff := s.persistentPeersBackoff[pubStr]
|
||||
nextBackoff := computeNextBackoff(currBackoff)
|
||||
s.persistentPeersBackoff[pubStr] = nextBackoff
|
||||
// Now, determine the appropriate backoff to use for the retry.
|
||||
backoff, ok := s.persistentPeersBackoff[pubStr]
|
||||
if !ok {
|
||||
// If an existing backoff was unknown, use the default.
|
||||
backoff = defaultBackoff
|
||||
} else {
|
||||
// Otherwise, use a previous backoff to compute the
|
||||
// subsequent randomized exponential backoff duration.
|
||||
backoff = computeNextBackoff(backoff)
|
||||
}
|
||||
|
||||
s.persistentPeersBackoff[pubStr] = backoff
|
||||
|
||||
// We choose not to wait group this go routine since the Connect
|
||||
// call can stall for arbitrarily long if we shutdown while an
|
||||
// outbound connection attempt is being made.
|
||||
go func() {
|
||||
srvrLog.Debugf("Scheduling connection re-establishment to "+
|
||||
"persistent peer %v in %s", p, nextBackoff)
|
||||
"persistent peer %v in %s", p, backoff)
|
||||
|
||||
select {
|
||||
case <-time.After(nextBackoff):
|
||||
case <-time.After(backoff):
|
||||
case <-s.quit:
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user