mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +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] = append(
|
||||||
s.persistentConnReqs[pubStr], connReq)
|
s.persistentConnReqs[pubStr], connReq)
|
||||||
|
|
||||||
// Compute the subsequent backoff duration.
|
// Now, determine the appropriate backoff to use for the retry.
|
||||||
currBackoff := s.persistentPeersBackoff[pubStr]
|
backoff, ok := s.persistentPeersBackoff[pubStr]
|
||||||
nextBackoff := computeNextBackoff(currBackoff)
|
if !ok {
|
||||||
s.persistentPeersBackoff[pubStr] = nextBackoff
|
// 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
|
// We choose not to wait group this go routine since the Connect
|
||||||
// call can stall for arbitrarily long if we shutdown while an
|
// call can stall for arbitrarily long if we shutdown while an
|
||||||
// outbound connection attempt is being made.
|
// outbound connection attempt is being made.
|
||||||
go func() {
|
go func() {
|
||||||
srvrLog.Debugf("Scheduling connection re-establishment to "+
|
srvrLog.Debugf("Scheduling connection re-establishment to "+
|
||||||
"persistent peer %v in %s", p, nextBackoff)
|
"persistent peer %v in %s", p, backoff)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-time.After(nextBackoff):
|
case <-time.After(backoff):
|
||||||
case <-s.quit:
|
case <-s.quit:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user