From f84c43b8f79b6294f44c43ff3e4596da66525843 Mon Sep 17 00:00:00 2001 From: DanB Date: Thu, 8 Sep 2016 12:37:29 +0200 Subject: [PATCH] Fix session stripping in SMG.ActiveSessions --- sessionmanager/smgeneric.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sessionmanager/smgeneric.go b/sessionmanager/smgeneric.go index 051ab6486..595a6cfbb 100644 --- a/sessionmanager/smgeneric.go +++ b/sessionmanager/smgeneric.go @@ -618,8 +618,8 @@ func (self *SMGeneric) ActiveSessions(fltrs map[string]string, count bool) (aSes } } if len(fltrs) != 0 { // Still have some filters to match - for i, s := range remainingSessions { - sMp, err := s.eventStart.AsMapStringString() + for i := 0; i < len(remainingSessions); { + sMp, err := remainingSessions[i].eventStart.AsMapStringString() if err != nil { return nil, 0, err } @@ -633,10 +633,11 @@ func (self *SMGeneric) ActiveSessions(fltrs map[string]string, count bool) (aSes break } } - if !matchingAll { // Strip the session from remaining ones with emptying the session to be garbage collected - remainingSessions[i] = remainingSessions[len(remainingSessions)-1] - remainingSessions = remainingSessions[:len(remainingSessions)-1] + if !matchingAll { + remainingSessions = append(remainingSessions[:i], remainingSessions[i+1:]...) + continue // if we have stripped, don't increase index so we can check next element by next run } + i++ } } if count {