From 77a6315dfb779ac796758232b2b57d045242b1c3 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 29 Feb 2016 13:16:58 +0100 Subject: [PATCH] Wipe sessions when they expire. --- src/controller/controller_statistics.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/controller/controller_statistics.cpp b/src/controller/controller_statistics.cpp index 59a9ab2e..27b623c7 100644 --- a/src/controller/controller_statistics.cpp +++ b/src/controller/controller_statistics.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "controller_statistics.h" @@ -93,9 +94,17 @@ void Controller::SharedMemStats(void * config){ statServer.parseEach(parseStatistics); //wipe old statistics if (sessions.size()){ + std::list mustWipe; unsigned long long cutOffPoint = Util::epoch() - STAT_CUTOFF; for (std::map::iterator it = sessions.begin(); it != sessions.end(); it++){ it->second.wipeOld(cutOffPoint); + if (!it->second.hasData()){ + mustWipe.push_back(it->first); + } + } + while (mustWipe.size()){ + sessions.erase(mustWipe.front()); + mustWipe.pop_front(); } } }