Added delay on error from disconnect session

This commit is contained in:
Trial97
2021-05-24 15:41:59 +03:00
committed by Alexandru Ionut Tripon
parent deec88bea3
commit d67ff5e163

View File

@@ -559,7 +559,11 @@ func (sS *SessionS) debitLoopSession(s *Session, sRunIdx int,
dscReason = err.Error()
}
// try to disconect the session n times before we force terminate it on our side
fib := utils.Fib()
for i := 0; i < sS.cgrCfg.SessionSCfg().TerminateAttempts; i++ {
if i != 0 { // not the first iteration
time.Sleep(time.Duration(fib()) * time.Millisecond)
}
if err = sS.disconnectSession(s, dscReason); err == nil {
s.Unlock()
return
@@ -594,10 +598,17 @@ func (sS *SessionS) debitLoopSession(s *Session, sRunIdx int,
s.Lock()
defer s.Unlock()
// try to disconect the session n times before we force terminate it on our side
fib := utils.Fib()
for i := 0; i < sS.cgrCfg.SessionSCfg().TerminateAttempts; i++ {
if i != 0 { // not the first iteration
time.Sleep(time.Duration(fib()) * time.Millisecond)
}
if err = sS.disconnectSession(s, utils.ErrInsufficientCredit.Error()); err == nil {
return
}
utils.Logger.Warning(
fmt.Sprintf("<%s> could not disconnect session: %s, error: %s",
utils.SessionS, s.cgrID(), err.Error()))
}
utils.Logger.Warning(
fmt.Sprintf("<%s> could not disconnect session: <%s>, error: <%s>",