From 401f1ce9962a84ba5bee10970c7fd53350544b79 Mon Sep 17 00:00:00 2001 From: DanB Date: Thu, 12 Jan 2017 09:11:38 +0100 Subject: [PATCH] Revert "SMG.replicateSessions with connections in params" This reverts commit d235f5c55f12f44a9a3cae961b3d8f18262c34de. --- sessionmanager/smgeneric.go | 26 +++++++++----------------- utils/consts.go | 1 - 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/sessionmanager/smgeneric.go b/sessionmanager/smgeneric.go index 8927efdbc..f16b18765 100644 --- a/sessionmanager/smgeneric.go +++ b/sessionmanager/smgeneric.go @@ -176,7 +176,7 @@ func (smg *SMGeneric) ttlTerminate(s *SMGSession, tmtr *smgSessionTerminator) { cdr.Usage = s.TotalUsage var reply string smg.cdrsrv.Call("CdrsV1.ProcessCDR", cdr, &reply) - smg.replicateSessions(s.CGRID, smg.smgReplConns) + smg.replicateSessions(s.CGRID) } func (smg *SMGeneric) recordASession(s *SMGSession) { @@ -446,26 +446,18 @@ func (smg *SMGeneric) sessionRelocate(initialID, cgrID, newOriginID string) erro } // replicateSessions will replicate session based on configuration -func (smg *SMGeneric) replicateSessions(cgrID string, smgReplConns []*SMGReplicationConn) (err error) { +func (smg *SMGeneric) replicateSessions(cgrID string) (err error) { if smg.cgrCfg.SmGenericConfig.DebitInterval != 0 { return } smg.aSessionsMux.RLock() var aSessions []*SMGSession - aSs, hasIt := smg.activeSessions[cgrID] - if !hasIt { - err = utils.NewCGRError(utils.SMG, - utils.NotFoundCaps, utils.ItemNotFound, - fmt.Sprintf("session with cgrid <%s> was not found in active sessions", cgrID)) - } else { - err = utils.Clone(aSs, &aSessions) - } - smg.aSessionsMux.RUnlock() - if err != nil { + if err = utils.Clone(smg.activeSessions[cgrID], &aSessions); err != nil { return } + smg.aSessionsMux.RUnlock() var wg sync.WaitGroup - for _, rplConn := range smgReplConns { + for _, rplConn := range smg.smgReplConns { if rplConn.Synchronous { wg.Add(1) } @@ -719,7 +711,7 @@ func (smg *SMGeneric) UpdateSession(gev SMGenericEvent, clnt rpcclient.RpcClient if err != nil { return } - smg.replicateSessions(initialCGRID, smg.smgReplConns) + smg.replicateSessions(initialCGRID) } smg.resetTerminatorTimer(cgrID, gev.GetSessionTTL(), gev.GetSessionTTLLastUsed(), gev.GetSessionTTLUsage()) var lastUsed *time.Duration @@ -743,7 +735,7 @@ func (smg *SMGeneric) UpdateSession(gev SMGenericEvent, clnt rpcclient.RpcClient return } } - defer smg.replicateSessions(gev.GetCGRID(utils.META_DEFAULT), smg.smgReplConns) + defer smg.replicateSessions(gev.GetCGRID(utils.META_DEFAULT)) for _, s := range aSessions[cgrID] { var maxDur time.Duration if maxDur, err = s.debit(maxUsage, lastUsed); err != nil { @@ -772,7 +764,7 @@ func (smg *SMGeneric) TerminateSession(gev SMGenericEvent, clnt rpcclient.RpcCli if err != nil && err != utils.ErrMandatoryIeMissing { return } - smg.replicateSessions(initialCGRID, smg.smgReplConns) + smg.replicateSessions(initialCGRID) } sessionIDs := []string{cgrID} if gev.HasField(utils.OriginIDPrefix) { // OriginIDPrefix is present, OriginID will not be anymore considered @@ -810,7 +802,7 @@ func (smg *SMGeneric) TerminateSession(gev SMGenericEvent, clnt rpcclient.RpcCli } } hasActiveSession = true - defer smg.replicateSessions(sessionID, smg.smgReplConns) + defer smg.replicateSessions(sessionID) s := aSessions[sessionID][0] if errUsage != nil { usage = s.TotalUsage - s.LastUsage + lastUsed diff --git a/utils/consts.go b/utils/consts.go index 2a56413f2..af16f395b 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -311,7 +311,6 @@ const ( Cache = "cache" NotFoundCaps = "NOT_FOUND" ItemNotFound = "item not found" - SessionNotFound = "session not found" ItemNotCloneable = "item not cloneable" NotCloneableCaps = "NOT_CLONEABLE" ServerErrorCaps = "SERVER_ERROR"