From a15ea64e4e568d7040634d686852489c502d41dd Mon Sep 17 00:00:00 2001 From: Thulinma Date: Sun, 26 Aug 2012 20:46:03 +0200 Subject: [PATCH] Fix controller keeping stats for deleted streams - now deletes stats 2 minutes after receiving the last updates. --- src/controller.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/controller.cpp b/src/controller.cpp index a6440b00..a6b01c10 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -252,6 +252,15 @@ void startStream(std::string name, JSON::Value & data){ } } +void CheckStats(JSON::Value & stats){ + unsigned int currTime = time(0); + for (JSON::ObjIter jit = stats.ObjBegin(); jit != stats.ObjEnd(); jit++){ + if (currTime - lastBuffer[jit->first] > 120){ + stats.removeMember(jit->first); + } + } +} + void CheckAllStreams(JSON::Value & data){ unsigned int currTime = time(0); bool changed = false; @@ -355,6 +364,7 @@ int main(int argc, char ** argv){ processchecker = time(0); Connector::CheckProtocols(Connector::Storage["config"]["protocols"]); Connector::CheckAllStreams(Connector::Storage["streams"]); + Connector::CheckStats(Connector::Storage["statistics"]); } if (conf.getBool("uplink") && time(0) - lastuplink > UPLINK_INTERVAL){ lastuplink = time(0);