diff --git a/src/controller/controller_statistics.cpp b/src/controller/controller_statistics.cpp index 99207f3a..24b45300 100644 --- a/src/controller/controller_statistics.cpp +++ b/src/controller/controller_statistics.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -105,9 +106,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(); } } Controller::checkServerLimits(); /*LTS*/