connmgr: Retry only if below target outbound conns
This commit is contained in:
parent
aca9fc040c
commit
d8a6de461f
1 changed files with 6 additions and 4 deletions
|
@ -171,11 +171,11 @@ type ConnManager struct {
|
|||
// retry duration. Otherwise, if required, it makes a new connection request.
|
||||
// After maxFailedConnectionAttempts new connections will be retried after the
|
||||
// configured retry duration.
|
||||
func (cm *ConnManager) handleFailedConn(c *ConnReq, retry bool) {
|
||||
func (cm *ConnManager) handleFailedConn(c *ConnReq) {
|
||||
if atomic.LoadInt32(&cm.stop) != 0 {
|
||||
return
|
||||
}
|
||||
if retry && c.Permanent {
|
||||
if c.Permanent {
|
||||
c.retryCount++
|
||||
d := time.Duration(c.retryCount) * cm.cfg.RetryDuration
|
||||
if d > maxRetryDuration {
|
||||
|
@ -240,7 +240,9 @@ out:
|
|||
go cm.cfg.OnDisconnection(connReq)
|
||||
}
|
||||
|
||||
cm.handleFailedConn(connReq, msg.retry)
|
||||
if uint32(len(conns)) < cm.cfg.TargetOutbound && msg.retry {
|
||||
cm.handleFailedConn(connReq)
|
||||
}
|
||||
} else {
|
||||
log.Errorf("Unknown connection: %d", msg.id)
|
||||
}
|
||||
|
@ -249,7 +251,7 @@ out:
|
|||
connReq := msg.c
|
||||
connReq.updateState(ConnFailed)
|
||||
log.Debugf("Failed to connect to %v: %v", connReq, msg.err)
|
||||
cm.handleFailedConn(connReq, true)
|
||||
cm.handleFailedConn(connReq)
|
||||
}
|
||||
|
||||
case <-cm.quit:
|
||||
|
|
Loading…
Reference in a new issue