mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-12 02:26:26 +05:00
Simplified SMGeneric.ttlTerminate to avoid loops via updateSession
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
"enabled": true,
|
||||
"rater": "internal",
|
||||
"cdrs": "internal",
|
||||
"session_ttl": "10ms",
|
||||
"session_ttl": "50ms",
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
@@ -687,13 +687,13 @@ func TestSMGVoiceSessionTTL(t *testing.T) {
|
||||
t.Errorf("Expected: %f, received: %f", eAcntVal, acnt.BalanceMap[utils.MONETARY].GetTotalValue())
|
||||
}
|
||||
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
if err := smgRPC.Call("SMGenericV1.ActiveSessions", utils.AttrSMGGetActiveSessions{RunID: utils.StringPointer(utils.META_DEFAULT), OriginID: utils.StringPointer("12360")}, &aSessions); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(aSessions) != 1 {
|
||||
t.Errorf("Unexpected number of sessions received: %+v", aSessions)
|
||||
} else if aSessions[0].Usage != time.Duration(150)*time.Second+time.Duration(10)*time.Millisecond {
|
||||
t.Errorf("Expecting 2m30s10ms, received usage: %v", aSessions[0].Usage)
|
||||
} else if aSessions[0].Usage != time.Duration(150)*time.Second+time.Duration(50)*time.Millisecond {
|
||||
t.Errorf("Expecting 2m30s50ms, received usage: %v", aSessions[0].Usage)
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -78,15 +78,13 @@ func (self *SMGeneric) resetTerminatorTimer(uuid string, ttl time.Duration, ttlL
|
||||
|
||||
// Called when a session timeouts
|
||||
func (self *SMGeneric) ttlTerminate(s *SMGSession, tmtr *smgSessionTerminator) {
|
||||
evUpdate := s.eventStart
|
||||
evUpdate[utils.USAGE] = tmtr.ttl.Seconds()
|
||||
debitUsage := tmtr.ttl
|
||||
if tmtr.ttlUsage != nil {
|
||||
evUpdate[utils.USAGE] = tmtr.ttlUsage.Seconds()
|
||||
debitUsage = *tmtr.ttlUsage
|
||||
}
|
||||
if tmtr.ttlLastUsed != nil {
|
||||
evUpdate[utils.LastUsed] = tmtr.ttlLastUsed.Seconds()
|
||||
for _, s := range self.getSession(s.eventStart.GetUUID()) {
|
||||
s.debit(debitUsage, tmtr.ttlLastUsed)
|
||||
}
|
||||
self.SessionUpdate(evUpdate, nil)
|
||||
/*self.sessionEnd(s.eventStart.GetUUID(), s.TotalUsage())
|
||||
cdr := s.eventStart.AsStoredCdr(self.cgrCfg, self.timezone)
|
||||
cdr.Usage = s.TotalUsage()
|
||||
|
||||
Reference in New Issue
Block a user