From 0c0bb5b3bf2161791078a733886e5f16eb2f35b1 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Wed, 11 Jan 2017 18:29:46 +0100 Subject: [PATCH] Fixed stream statistics sometimes holding invalid values --- src/controller/controller_statistics.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/controller/controller_statistics.cpp b/src/controller/controller_statistics.cpp index f3cd5469..1fe65e81 100644 --- a/src/controller/controller_statistics.cpp +++ b/src/controller/controller_statistics.cpp @@ -345,11 +345,19 @@ void Controller::statSession::update(unsigned long index, IPC::statExchange & da streamStats[streamName].viewers++; sessionType = SESS_VIEWER; } - streamStats[streamName].upBytes += currUp; - streamStats[streamName].downBytes += currDown; + if (!streamName.size() || streamName[0] == 0){ + if (streamStats.count(streamName)){streamStats.erase(streamName);} + }else{ + streamStats[streamName].upBytes += currUp; + streamStats[streamName].downBytes += currDown; + } }else{ - streamStats[streamName].upBytes += currUp - prevUp; - streamStats[streamName].downBytes += currDown - prevDown; + if (!streamName.size() || streamName[0] == 0){ + if (streamStats.count(streamName)){streamStats.erase(streamName);} + }else{ + streamStats[streamName].upBytes += currUp - prevUp; + streamStats[streamName].downBytes += currDown - prevDown; + } if (sessionType == SESS_UNSET){ if (data.connector() == "INPUT"){ sessionType = SESS_INPUT;